You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Martin Lüthi <an...@tnoo.net> on 2002/12/19 12:22:26 UTC

i18n best practice

Hello

The i18n transformer is a great solution for the creation of multilingual
content. So far I have found no documentation on how to best implement
language change. ATM I see two possibilities:

(1) create URL's with ?locale=xx_YY 

(2) store the state of the actual user locale in the session

While (1) is straightforward to achieve with stylesheet parameters, it feels
somewhat messy. Solution (2) seems more elegant, however I need some advice
how to:

(2a) store and change the locale in the session
(2b) query the locale from the session and handle it to the i18n-transformer

I guess (2b) is what LocaleAction is for. 

Thanks for all hints

Martin


-- 
Martin L�thi                 answer@tnoo.net




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: i18n best practice

Posted by Konstantin Piroumian <kp...@apache.org>.
From: <an...@tnoo.net>

> Thank you Konstantin!

Not at all.

>
> "Konstantin Piroumian" <kp...@apache.org> writes:
> > My mail application could not open your message correctly due to some
error
> > in encoding, so my answers are marked by [KP]:
>
> Gnus wanted to know the encoding style (latin-1), sorry!
>
> > [KP] i18n transformer is not responsible for language selection, it
accepts
> > a 'locale' parameter (since C2.0.4) which can be generated by a variety
of
> > ways: URI parts, request parameters, retrieved from a DB and of course
> > generated by the LocaleAction.
>
> That's what I understood from the samples and experimentation.
>
> > (1) create URL's with ?locale=xx_YY
> >
> > [KP] This is a common technic for 'changing' the current language (which
> > will be stored in session by LocaleAction if configured)
>
> This is what I tried. My problem was, that subsequent requests used again
the
> first locale. With a little experimentation I found that this depends on
> cookies (of course, the session identification!).  This is why I asked
>
> > (2) store the state of the actual user locale in the session
> >
> > [KP] This is possible for ages by the LocaleAction. And even more, you
can
> > also store locale in a cookie, so that when the user re-visits your site
> > you'll get the locale that he's selected last time.
> >
> > While (1) is straightforward to achieve with stylesheet parameters, it
feels
> > somewhat messy. Solution (2) seems more elegant, however I need some
advice
> > how to:
> >
> > [KP] For (1) you will need to add '?locale=xx_YY' only in one place -
this
> > link for language change.
>
> ok
>
> > (2a) store and change the locale in the session
> > (2b) query the locale from the session and handle it to the
i18n-transformer
> >
> > I guess (2b) is what LocaleAction is for.
> >
> > [KP] LocaleAction is both: for 2a and 2b. Simply take a look at the i18n
> > samples in /webapp/samples/i18n directory). (Note, that there is also
the
> > old i18n directory in /webapp/i18n in C2.0.x versions - it should be
> > removed, do not look at it).
>
> Well, as far as I see, everything works now when cookies are enabled.
Would
> URL-rewriting be an options if no cookies are allowed?

Usually, the URL-rewriting is performed by the server (in WebLogic at least
and AFAIR in Tomcat too) if client does not support cookies. From the
application developer's POV the session tracking mechanism is transparent,
so you don't have to bother how is your session tracked. The only thing to
remember is that when you have external links (that refer to another
application context) or redirects then you'll have to explicitely encode the
session id in your URLs.

I hope you've found the needed configuration parameters that you need to set
to allow the locale information to be saved in session (and create a session
if needed).

Konstantin

>
> Martin
>
> --
> Martin Lüthi                 answer@tnoo.net
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: i18n best practice

Posted by Martin Lüthi <an...@tnoo.net>.
Thank you Konstantin!

"Konstantin Piroumian" <kp...@apache.org> writes:
> My mail application could not open your message correctly due to some error
> in encoding, so my answers are marked by [KP]:

Gnus wanted to know the encoding style (latin-1), sorry!

> [KP] i18n transformer is not responsible for language selection, it accepts
> a 'locale' parameter (since C2.0.4) which can be generated by a variety of
> ways: URI parts, request parameters, retrieved from a DB and of course
> generated by the LocaleAction.

That's what I understood from the samples and experimentation.

> (1) create URL's with ?locale=xx_YY
> 
> [KP] This is a common technic for 'changing' the current language (which
> will be stored in session by LocaleAction if configured)

This is what I tried. My problem was, that subsequent requests used again the
first locale. With a little experimentation I found that this depends on
cookies (of course, the session identification!).  This is why I asked

> (2) store the state of the actual user locale in the session
> 
> [KP] This is possible for ages by the LocaleAction. And even more, you can
> also store locale in a cookie, so that when the user re-visits your site
> you'll get the locale that he's selected last time.
> 
> While (1) is straightforward to achieve with stylesheet parameters, it feels
> somewhat messy. Solution (2) seems more elegant, however I need some advice
> how to:
> 
> [KP] For (1) you will need to add '?locale=xx_YY' only in one place - this
> link for language change.

ok

> (2a) store and change the locale in the session
> (2b) query the locale from the session and handle it to the i18n-transformer
> 
> I guess (2b) is what LocaleAction is for.
> 
> [KP] LocaleAction is both: for 2a and 2b. Simply take a look at the i18n
> samples in /webapp/samples/i18n directory). (Note, that there is also the
> old i18n directory in /webapp/i18n in C2.0.x versions - it should be
> removed, do not look at it).

Well, as far as I see, everything works now when cookies are enabled. Would
URL-rewriting be an options if no cookies are allowed? 

Martin

-- 
Martin L�thi                 answer@tnoo.net



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: i18n best practice

Posted by Konstantin Piroumian <kp...@apache.org>.
Hi!

My mail application could not open your message correctly due to some error
in encoding, so my answers are marked by [KP]:

----- Original Message -----
From: <an...@tnoo.net>
To: <co...@xml.apache.org>
Sent: Thursday, December 19, 2002 14:22
Subject: i18n best practice


Hello

The i18n transformer is a great solution for the creation of multilingual
content. So far I have found no documentation on how to best implement
language change. ATM I see two possibilities:

[KP] i18n transformer is not responsible for language selection, it accepts
a 'locale' parameter (since C2.0.4) which can be generated by a variety of
ways: URI parts, request parameters, retrieved from a DB and of course
generated by the LocaleAction.

(1) create URL's with ?locale=xx_YY

[KP] This is a common technic for 'changing' the current language (which
will be stored in session by LocaleAction if configured)

(2) store the state of the actual user locale in the session

[KP] This is possible for ages by the LocaleAction. And even more, you can
also store locale in a cookie, so that when the user re-visits your site
you'll get the locale that he's selected last time.

While (1) is straightforward to achieve with stylesheet parameters, it feels
somewhat messy. Solution (2) seems more elegant, however I need some advice
how to:

[KP] For (1) you will need to add '?locale=xx_YY' only in one place - this
link for language change.

(2a) store and change the locale in the session
(2b) query the locale from the session and handle it to the i18n-transformer

I guess (2b) is what LocaleAction is for.

[KP] LocaleAction is both: for 2a and 2b. Simply take a look at the i18n
samples in /webapp/samples/i18n directory). (Note, that there is also the
old i18n directory in /webapp/i18n in C2.0.x versions - it should be
removed, do not look at it).

[KP] Konstantin

Thanks for all hints

Martin


--
Martin L?thi                 answer@tnoo.net




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>