You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Enrico Ballarin Dolfin <en...@swissonline.ch> on 2003/08/27 16:55:04 UTC

i18n problem setting the locale

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


[SUMMARY] i18n problem setting the locale

Posted by Konstantin Piroumian <kp...@apache.org>.
From: "Enrico Ballarin Dolfin" <en...@swissonline.ch>

> Thanks for your valuable help!
> I could solve the problem using the LocaleAction as you suggested.

No problems.

It's a good idea to write down the experience and solutions on Wiki and/or
post a message with [SUMMARY] added in the subject line when solution to a
problem is found (see the subject).

I think that this particular case would be useful to others too.

Regards,
  Konstantin

>
> Enrico
>
> ----- Original Message -----
> From: Konstantin Piroumian <kp...@apache.org>
> To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
> <en...@swissonline.ch>
> Sent: Thursday, August 28, 2003 11:16 AM
> Subject: Re: i18n problem setting the locale
>
>
> > From: "Enrico Ballarin Dolfin" <en...@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 <kp...@apache.org>
> > > To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
> > > <en...@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" <en...@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
> >
>
>
> ---------------------------------------------------------------------
> 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


Re: i18n problem setting the locale

Posted by Enrico Ballarin Dolfin <en...@swissonline.ch>.
Thanks for your valuable help!
I could solve the problem using the LocaleAction as you suggested.

Enrico

----- Original Message -----
From: Konstantin Piroumian <kp...@apache.org>
To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
<en...@swissonline.ch>
Sent: Thursday, August 28, 2003 11:16 AM
Subject: Re: i18n problem setting the locale


> From: "Enrico Ballarin Dolfin" <en...@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 <kp...@apache.org>
> > To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
> > <en...@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" <en...@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
>


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


Re: i18n problem setting the locale

Posted by Konstantin Piroumian <kp...@apache.org>.
From: "Enrico Ballarin Dolfin" <en...@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 <kp...@apache.org>
> To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
> <en...@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" <en...@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


Re: i18n problem setting the locale

Posted by Enrico Ballarin Dolfin <en...@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.

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 <kp...@apache.org>
To: <us...@cocoon.apache.org>; Enrico Ballarin Dolfin
<en...@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" <en...@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


Re: i18n problem setting the locale

Posted by Konstantin Piroumian <kp...@apache.org>.
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" <en...@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


Re: i18n problem setting the locale

Posted by Mustafa Yalniz <ya...@bumed.org.tr>.
Hi Enrico

Have you tried to use an action to get the local language?
I'm not a big expert, this is only a suggestion...
I think the most qualified person to answer your question is Konstantin 
Piroumian.

rgds,
Mustafa

At 16:55 27.08.2003 +0200, you wrote:
>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