cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Askild Aaberg Olsen" <ask...@xangeli.com>
Subject Re: Cocoon and Internationalization
Date Tue, 11 May 2004 14:08:17 GMT
Upayavira wrote:
> Askild Aaberg Olsen wrote:
> >This is actually my current approach, but implemented with sitemap 
> >parameters, a stylesheet and cinclude.
> >
> ><map:match pattern="**/*.*">
> >	<map:generate type="directory" src="{1}">
> >		<map:parameter name="include" value="{2}_?(.*).{3}"/>
> >	</map:generate>
> >	<map:transform type="xslt" src="match.lang.xslt">
> >		<map:parameter name="lang" 
> value="{request-param:lang}"/>
> >		<map:parameter name="path" value="{1}"/>
> >	</map:transform>
> >	<map:transform type="cinclude"/>
> >	<map:serialize type="xml"/>
> ></map:match>
> >
> >The stylesheet implements the selection logic to find the 
> correct file, 
> >and if it doesn't find it, serves the closest match.
> >  
> >
> Now that is interesting. If you instead did:
> 
> 	<map:act type="locale">
> 		<map:transform type="xslt" src="match.lang.xslt">
> 			<map:parameter name="request-lang" 
> value="{request-param:lang}"/>
> 			<map:parameter name="locale-lang" 
> value="{locale:lang}"/>
> 			<map:parameter name="path" value="{1}"/>
> 		</map:transform>
> 	</map:act>
> 
> You would be able to code your stylesheet to handle the 
> locale provided 
> by the user's browser, not just a request parameter.

Nice one, but in my case this sitemap is actually called from another
pipeline, that provides the actual lang request-parameter. I have a separate
piece logic to work out the right locale (not only based on the users
locale).

> Would you be willing to post (or send me privately) your stylesheet as it
currently stands?

Of course!
I rely on your and the Cocoon community's work all day long, so it's just
decent to give something back.

The filename pattern is <filename>_<lang>.<ext>, and the idea is to take
the
file with the longest <lang>-string that matches the complete or partial
language.
If no match is found, just produce the last one (wich is also the default
language, usually english or norwegian (!) for norwegian only sites.

> >It works, but it's not rock-solid.
> >
> It looks good to me, so far.

Thanks, but you haven't seen the stylesheet yet ;)
That's the weak link, since it's not able to compute the 100% correct
language.
But it's still good enough for me, event if it doesn't work for all cases. 

> >A cocoon component that implements this
> >would be really useful!
> >  
> >
> Yea. But there's also something to be said for the simple component 
> approach that you've taken. I'll mull on this more.
> 
> Regards, Upayavira

Regards, Askild

Mime
View raw message