You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Martin Dietze <di...@fh-wedel.de> on 2007/07/13 20:18:26 UTC

T5: how to obtain the current session's locale in a Translator?

Hi,

 I am currently working on Ted's DatePicker component. It uses
a Translator for parsing the entered String and convert it into
a Date object. The Translator is registered like this:

| public static void contributeTranslatorSource(MappedConfiguration<String,
|         Translator> configuration) {
|     configuration.add("jsCalendarDateTranslator", new DateTranslator());
| }

My problem is the date format is pretty locale-dependent. In
Germany we would use something like dd.mm.yy or dd.mm.yyyy
while in the English-speaking world we could have stuff like 
yyyy/mm/dd.

Ideally I'd like the Translator to obtain the currently set
locale (set using the ThreadLocale service in my main layout
module which has a Language-dropdown) and use the date format
which is most appropriate for it.

However I found that any attempt to @Inject Locale,
ThreadLocale or PersistentLocale always gave me null values.
If I interpret the documentation well this should be expected
anyway since a Translator is not a component (?), but what else
can I do?

Cheers,

Martin

-- 
----------- / http://herbert.the-little-red-haired-girl.org / -------------
=+= 
In C you need #define to get real constants, like "#define FOO (rand())"

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