cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantin Piroumian" <kpiroum...@apache.org>
Subject Re: i18n problem setting the locale
Date Thu, 28 Aug 2003 09:16:20 GMT
From: "Enrico Ballarin Dolfin" <enrico2@swissonline.ch>

> Thanks Konstantin
>
> I have already added the 'locale' attribute with the selected language to
> all the links and it works.
>
> My problem is that if you access the startpage without the 'locale'
> parameter in the URL e.g.
> "http://localhost:8080/startpage" the 'locale' attribute will not be
> initialized, except if you choose explicitly an other language in the
> startpage.

AFAIR, the locale selection algorythm in LocaleAction is the following:
    - check for 'locale' in request parameters
    - then in request attributes
    - then in session (if turned on)
    - then in cookies (...)
    - then it calls getLocale() or something like that from request, which
will give you the Accept-Language header value which is set by the user in
his browser.

If none of this is found then English is used.
Probably, you could add a 'default' parameter to LocaleAction to initialize
locale value with something different.

-- Konstantin

>
> I'm trying now also with sessions (sunShine in cocoon 2.0.4), but I cannot
> find a way to get the default language of the computer accessing the page.
>
> Enrico
>
> ----- Original Message -----
> From: Konstantin Piroumian <kpiroumian@apache.org>
> To: <users@cocoon.apache.org>; Enrico Ballarin Dolfin
> <enrico2@swissonline.ch>
> Sent: Thursday, August 28, 2003 8:57 AM
> Subject: Re: i18n problem setting the locale
>
>
> > I see two ways of preserving the selected locale (if you don't want to
use
> > sessions):
> >
> > 1. Add 'locale' attribute with the selected language to each link on the
> > page. You can pass this paramter to a transformer that will do the job.
> >
> > 2. Use cookies on the client side to store the locale. This can be
turned
> on
> > by using LocaleAction and adding <store-in-cookie>true</store-in-cookie>
> > parameter.
> >
> > You can see an example of how to use LocaleAction in i18n samples.
> >
> > -- Konstantin
> >
> > From: "Enrico Ballarin Dolfin" <enrico2@swissonline.ch>
> >
> > > Hi
> > >
> > > we would like to internationalize our site and to do this we are
> > > experimenting on a small prototype.
> > >
> > > We have a startpage where we can select other laguages and a picture
> with
> > a
> > > link to a second page.
> > >
> > > Basically we would like to select the wished language or accept the
> > default
> > > language on the startpage and then continue to the second page using
the
> > > same language. The language selection will be done only on the
> startpage.
> > > To achive this behaviour we are appending to the existing links a
> > parameter
> > > e.g. "http://localhost:8080/startpage?locale=fr" for the french
> language,
> > if
> > > we have selected it on the startpage.
> > >
> > > The first time that you arrive to the startpage there is no such
> > parameter:
> > > "http://localhost:8080/startpage" so that cocoon displays the
startpage
> in
> > > the computer default language e.g. "de" if a translation dictionary
for
> it
> > > exists, otherwise in english.
> > >
> > > If we change language on the startpage we get the same startpage
written
> > in
> > > this language with a link like
> "http://localhost:8080/startpage?locale=fr"
> > > and this will be processed from the same resource in the sitemap:
> > >
> > > <map:match pattern="startpage">
> > >   <map:generate src="test/resources/start.xml"/>
> > >   <map:transform type="i18n"/>
> > >   <map:transform src="test/styles/start.xsl">
> > >     <map:parameter name="use-request-parameter" value="true"/>
> > >   </map:transform>
> > >   <map:serialize/>
> > > </map:match>
> > >
> > > Later we can also go to the second page keeping the selected language.
> > >
> > > The problem is that if we accept in the startpage the default
language,
> we
> > > have a link to the second page without the locale parameter set e.g.
> > > "http://localhost:8080/startpage?locale=" .
> > >
> > > If we define in the start.xsl this parameter with default value
english,
> > > like this
> > >
> > > <xsl:param name="locale">en</xsl:param>
> > >
> > > we continue to the second page in english independently of which was
the
> > > default language of the startpage.
> > >
> > > What we need is to display the startpage in the default language,
> > optionally
> > > change the language redisplaying the start page in this language, and
> > > continue to the second page keeping the same language.
> > >
> > > I think we need to get the system default language and set the
"locale"
> > > variable to it as default, except if we call explicitly the page with
> the
> > > "locale" parameter set to a specific language e.g.
> > > "http://localhost:8080/startpage?locale=fr" .
> > >
> > > In our site we are using cocoon 2.0.4 and we not using sessions.
> > >
> > > Is there any way to achive this behaviour?
> > >
> > > Thanks a lot in advance
> > > Enrico
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message