You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by José Paumard <Jo...@orange.fr> on 2008/09/19 13:57:46 UTC
Handling of the browser locale
Hello all,
I know this looks like a faq, but to be sure, is T5 supposed to set the
current locale (the one we get by calling persistentLocale.get()) on
each request, and does it work ? My problem is that I get null when I
call persistentLocale.get(), with a locale set when I call
request.getLocale(), and corresponding to a declared locale in
tapestry.supported-locale. Am I missing something ?
Any info would be much appreciated,
José
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Handling of the browser locale
Posted by Ulrich Stärk <ul...@spielviel.de>.
Do you know, what locale gets injected here (ThreadLocale's, Request's or PersistentLocale's)? The
docs just say "The locale of the component" so I'd guess ThreadLocale's, but I'm not sure...
Uli
Geoff Callender schrieb:
> Not sure if I'm answering your question, but there's also
> @Inject
> private Locale _currentLocale;
> For an example of it in action try
> http://localhost:8080/jumpstart/examples/localization/bymessagecatalog .
>
> Geoff
>
> On 20/09/2008, at 12:19 AM, José Paumard wrote:
>
>> Ulrich,
>> Many thanks for your very precise answer ! Indeed
>> threadLocale.getLocale() is the way to go.
>> José
>>
>> Ulrich Stärk a écrit :
>>>
>>> I'm not 100% firm in this area but I believe that the user's locale
>>> gets stored in the ThreadLocale service. This service is responsible
>>> for storing the current thread's locale, i.e. the locale for which
>>> pages, messages etc. are being generated. The locale in ThreadLocale
>>> gets set by a combination of various other services.
>>>
>>> One of them is the PersistentLocale service. If you call
>>> persistentLocale.set(locale) a cookie is sent to the browser storing
>>> the desired locale. If you call persistentLocale.get() that value is
>>> read and returned. If no cookie has been set, this will be null. You
>>> can check that with persistentLocale.isSet().
>>>
>>> persistentLocale.set() also overwrites the locale in the ThreadLocale
>>> service. If the desired locale is not in supported-locales, Tapestry
>>> chooses the nearest matching locale. Thus, querying the ThreadLocale
>>> service will give you the locale that Tapestry has chosen to generate
>>> pages, messages etc. in, taking into account PersistentLocale's value
>>> as well as the Request's locale.
>>>
>>> So there are 3 ways to get the locale:
>>>
>>> - request.getLocale() will give you the locale, that the browser sent
>>> - persistentLocale.get() will give you the locale stored in a cookie
>>> in the user's browser or null, if no cookie is set
>>> - threadLocale.getLocale() will give you the locale choosen by
>>> Tapestry, taking into account the Request's locale,
>>> PersistentLocale's locale (will be chosen over the Request's locale)
>>> and supported-locales.
>>>
>>> HTH.
>>>
>>> Cheers,
>>>
>>> Uli
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Handling of the browser locale
Posted by Geoff Callender <ge...@gmail.com>.
Oops, I meant http://202.177.217.122:8080/jumpstart/examples/localization/bymessagecatalog
.
On 20/09/2008, at 1:14 AM, Geoff Callender wrote:
> Not sure if I'm answering your question, but there's also
> @Inject
> private Locale _currentLocale;
> For an example of it in action try http://localhost:8080/jumpstart/examples/localization/bymessagecatalog
> .
>
> Geoff
>
> On 20/09/2008, at 12:19 AM, José Paumard wrote:
>
>> Ulrich,
>> Many thanks for your very precise answer ! Indeed
>> threadLocale.getLocale() is the way to go.
>> José
>>
>> Ulrich Stärk a écrit :
>>>
>>> I'm not 100% firm in this area but I believe that the user's
>>> locale gets stored in the ThreadLocale service. This service is
>>> responsible for storing the current thread's locale, i.e. the
>>> locale for which pages, messages etc. are being generated. The
>>> locale in ThreadLocale gets set by a combination of various other
>>> services.
>>>
>>> One of them is the PersistentLocale service. If you call
>>> persistentLocale.set(locale) a cookie is sent to the browser
>>> storing the desired locale. If you call persistentLocale.get()
>>> that value is read and returned. If no cookie has been set, this
>>> will be null. You can check that with persistentLocale.isSet().
>>>
>>> persistentLocale.set() also overwrites the locale in the
>>> ThreadLocale service. If the desired locale is not in supported-
>>> locales, Tapestry chooses the nearest matching locale. Thus,
>>> querying the ThreadLocale service will give you the locale that
>>> Tapestry has chosen to generate pages, messages etc. in, taking
>>> into account PersistentLocale's value as well as the Request's
>>> locale.
>>>
>>> So there are 3 ways to get the locale:
>>>
>>> - request.getLocale() will give you the locale, that the browser
>>> sent
>>> - persistentLocale.get() will give you the locale stored in a
>>> cookie in the user's browser or null, if no cookie is set
>>> - threadLocale.getLocale() will give you the locale choosen by
>>> Tapestry, taking into account the Request's locale,
>>> PersistentLocale's locale (will be chosen over the Request's
>>> locale) and supported-locales.
>>>
>>> HTH.
>>>
>>> Cheers,
>>>
>>> Uli
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
Re: Handling of the browser locale
Posted by Geoff Callender <ge...@gmail.com>.
Not sure if I'm answering your question, but there's also
@Inject
private Locale _currentLocale;
For an example of it in action try http://localhost:8080/jumpstart/examples/localization/bymessagecatalog
.
Geoff
On 20/09/2008, at 12:19 AM, José Paumard wrote:
> Ulrich,
> Many thanks for your very precise answer ! Indeed
> threadLocale.getLocale() is the way to go.
> José
>
> Ulrich Stärk a écrit :
>>
>> I'm not 100% firm in this area but I believe that the user's locale
>> gets stored in the ThreadLocale service. This service is
>> responsible for storing the current thread's locale, i.e. the
>> locale for which pages, messages etc. are being generated. The
>> locale in ThreadLocale gets set by a combination of various other
>> services.
>>
>> One of them is the PersistentLocale service. If you call
>> persistentLocale.set(locale) a cookie is sent to the browser
>> storing the desired locale. If you call persistentLocale.get() that
>> value is read and returned. If no cookie has been set, this will be
>> null. You can check that with persistentLocale.isSet().
>>
>> persistentLocale.set() also overwrites the locale in the
>> ThreadLocale service. If the desired locale is not in supported-
>> locales, Tapestry chooses the nearest matching locale. Thus,
>> querying the ThreadLocale service will give you the locale that
>> Tapestry has chosen to generate pages, messages etc. in, taking
>> into account PersistentLocale's value as well as the Request's
>> locale.
>>
>> So there are 3 ways to get the locale:
>>
>> - request.getLocale() will give you the locale, that the browser sent
>> - persistentLocale.get() will give you the locale stored in a
>> cookie in the user's browser or null, if no cookie is set
>> - threadLocale.getLocale() will give you the locale choosen by
>> Tapestry, taking into account the Request's locale,
>> PersistentLocale's locale (will be chosen over the Request's
>> locale) and supported-locales.
>>
>> HTH.
>>
>> Cheers,
>>
>> Uli
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Handling of the browser locale
Posted by José Paumard <Jo...@orange.fr>.
Ulrich,
Many thanks for your very precise answer ! Indeed threadLocale.getLocale() is the way to go.
José
Ulrich Stärk a écrit :
>
> I'm not 100% firm in this area but I believe that the user's locale
> gets stored in the ThreadLocale service. This service is responsible
> for storing the current thread's locale, i.e. the locale for which
> pages, messages etc. are being generated. The locale in ThreadLocale
> gets set by a combination of various other services.
>
> One of them is the PersistentLocale service. If you call
> persistentLocale.set(locale) a cookie is sent to the browser storing
> the desired locale. If you call persistentLocale.get() that value is
> read and returned. If no cookie has been set, this will be null. You
> can check that with persistentLocale.isSet().
>
> persistentLocale.set() also overwrites the locale in the ThreadLocale
> service. If the desired locale is not in supported-locales, Tapestry
> chooses the nearest matching locale. Thus, querying the ThreadLocale
> service will give you the locale that Tapestry has chosen to generate
> pages, messages etc. in, taking into account PersistentLocale's value
> as well as the Request's locale.
>
> So there are 3 ways to get the locale:
>
> - request.getLocale() will give you the locale, that the browser sent
> - persistentLocale.get() will give you the locale stored in a cookie
> in the user's browser or null, if no cookie is set
> - threadLocale.getLocale() will give you the locale choosen by
> Tapestry, taking into account the Request's locale, PersistentLocale's
> locale (will be chosen over the Request's locale) and supported-locales.
>
> HTH.
>
> Cheers,
>
> Uli
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Handling of the browser locale
Posted by Ulrich Stärk <ul...@spielviel.de>.
I'm not 100% firm in this area but I believe that the user's locale gets stored in the ThreadLocale
service. This service is responsible for storing the current thread's locale, i.e. the locale for
which pages, messages etc. are being generated. The locale in ThreadLocale gets set by a combination
of various other services.
One of them is the PersistentLocale service. If you call persistentLocale.set(locale) a cookie is
sent to the browser storing the desired locale. If you call persistentLocale.get() that value is
read and returned. If no cookie has been set, this will be null. You can check that with
persistentLocale.isSet().
persistentLocale.set() also overwrites the locale in the ThreadLocale service. If the desired locale
is not in supported-locales, Tapestry chooses the nearest matching locale. Thus, querying the
ThreadLocale service will give you the locale that Tapestry has chosen to generate pages, messages
etc. in, taking into account PersistentLocale's value as well as the Request's locale.
So there are 3 ways to get the locale:
- request.getLocale() will give you the locale, that the browser sent
- persistentLocale.get() will give you the locale stored in a cookie in the user's browser or null,
if no cookie is set
- threadLocale.getLocale() will give you the locale choosen by Tapestry, taking into account the
Request's locale, PersistentLocale's locale (will be chosen over the Request's locale) and
supported-locales.
HTH.
Cheers,
Uli
José Paumard schrieb:
> Hello all,
>
> I know this looks like a faq, but to be sure, is T5 supposed to set the
> current locale (the one we get by calling persistentLocale.get()) on
> each request, and does it work ? My problem is that I get null when I
> call persistentLocale.get(), with a locale set when I call
> request.getLocale(), and corresponding to a declared locale in
> tapestry.supported-locale. Am I missing something ?
>
> Any info would be much appreciated,
>
> José
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org