lenya-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Kulemann <m...@rolf-kulemann.com>
Subject [I18N] Introducing UserLocaleAction??
Date Mon, 22 Dec 2003 19:50:33 GMT
Hello List,

as discussed before, I played around with actions and input modules to
determine the user agents locale aka accept-language.

I found out that I could use {request:locale} to get the locale as a
string. The problem using the request input module directly in a sitemap
is, that I couldn't notice, if a default locale is returned. The module
would return the servers default locale if there is no accept-language.

That is why I coded a really small action named UserLocaleAction, which
fails(return null) if user agent is not providing a accept-language.

In the case that the action fails(no user locale is available) I use
{page-envelope:default-language} i.e. in usecase.xmap.

To i18n the cms ui one has to change/extend usecase.xmap like this:

---------------------- usecase.xmap snippet ------------------
    <!-- RKUPATCH I18N  -->
    <map:resource name="i18n">
      <map:act type="user-locale">
        <map:transform type="i18n">      
          <map:parameter name="locale" value="{user-locale}"/>
          <map:parameter name="default-catalogue-id"
      <map:transform type="i18n">
        <map:parameter name="locale"
        <map:parameter name="default-catalogue-id"

    <map:resource name="style-cms-page">
      <map:transform src="xslt/util/page2xhtml.xsl">
        <map:parameter name="contextprefix"

      <map:call resource="i18n">
        <map:parameter name="catalogue-id" value="cmsui"/>

      <map:serialize type="xhtml-iso-8859-1"/>
------------------- /snippet -------------------------------

I added a resource with name "i18n" which is called, when the cmsui is

The i18n transformer is defined in global-sitemap.xmap. 

I also introduced language catalogues like cmsui_[,en,de].xml and
notification_[,en,de].xml (not used yet, only for demonstration). I put
the catalogues in the directory lenya/lenya/resources/i18n. Maybe you
know a better place for those files?

So, if I change the language in the browser I get the cms ui displayed
in that language on the next reload.

What I need now, is your opinion and if nothing is against it, I can
continue inserting i18n: tags in cms xsps.

Attached you will find the UserLocalAction.
A future plan could be to extend the UserLocaleAction in order to check
the user's locales against existing catalogues, but this is not
important now.

What do you think up to now? 


Always remember: 
	"There is inherently no silver bullet." - F.Brooks

PGP/GPG public key:

View raw message