Truly Dynamic I18N

184 views
Skip to first unread message

nicole

unread,
Jul 1, 2008, 11:02:54 AM7/1/08
to Google Web Toolkit
Hi all,

The GWT developer guide explains the various I18N options of GWT but
all of them have one thing in common: The locale cannot be changed
dynamically at runtime after a GWT application has been started.
However, it is a common use case that you want to change an
application’s locale at that point of time.

What I mean by truly dynamic I18N is that the end-user can change the
locale in the GUI at runtime. E.g., if the user changes a combo box
entry, then all GUI labels obtain the newly localized values. Or at
least, when the language is selected, the page refreshes with all the
labels in the selected language.

So, I was thinking maybe it's feasible in GWT and I might have missed
it in the documentation. Does anyone know how it can be done?

Thanks in advance for any helpful input.

olivier nouguier

unread,
Jul 1, 2008, 11:20:17 AM7/1/08
to Google-We...@googlegroups.com
Hi,
 I'm very suspicious of such "common use case", and IMSHO I think it goes against one of the GWT principle which is about delivering a (byte)code as adapted as possible to current user (browser && i18n permutations).

A "truly dynamic I18N" can be produced by using some custom labels (with some listener classic mechanism) and a lazy / eager load of resources, but at what cost ? Just to say, most of software (I mean not web based) need a restart when you change locale ...

"Things which matter most must never be at the mercy
        of things that matter least." ~ Goethe
--
"Quand le dernier arbre sera abattu, la dernière rivière asséchée, le dernier poisson péché, l'homme va s'apercevoir que l'argent n'est pas comestible"
- proverbe indien Cri

dolc...@gmail.com

unread,
Jul 1, 2008, 3:16:14 PM7/1/08
to Google Web Toolkit
Yes but you also need the I18N resources available at compile time,
you can't really have dynamic I18N resources (ie java properties
files).

On Jul 1, 11:20 am, "olivier nouguier" <olivier.nougu...@gmail.com>
wrote:

meng

unread,
Jul 1, 2008, 10:40:07 PM7/1/08
to Google Web Toolkit

olivier nouguier

unread,
Jul 2, 2008, 2:10:25 AM7/2/08
to Google-We...@googlegroups.com
Hum ... they might be also loaded at runtime (dynamically http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html#DynamicStringInternationalization ) using Dictionary (http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/index.html).

Were are using this in our project, those js (I18N.js) files are generated on the fly from the (server side) properties file. We're also generating some helper classes to check the use of key at compile time (but this task should perhaps be assumed by a GWT Generator, but we don't had time to investigate further).

Thomas Broyer

unread,
Jul 2, 2008, 9:08:25 AM7/2/08
to Google Web Toolkit

On 1 juil, 17:02, nicole <nicole....@gmail.com> wrote:
> Hi all,
>
> The GWT developer guide explains the various I18N options of GWT but
> all of them have one thing in common: The locale cannot be changed
> dynamically at runtime after a GWT application has been started.
> However, it is a common use case that you want to change an
> application’s locale at that point of time.
>
> What I mean by truly dynamic I18N is that the end-user can change the
> locale in the GUI at runtime. E.g., if the user changes a combo box
> entry, then all GUI labels obtain the newly localized values. Or at
> least, when the language is selected, the page refreshes with all the
> labels in the selected language.

This (the "at least" part) is really easy. Others already gave you the
link:
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html#SpecifyingLocale
...and you can see it implemented in the Showcase sample from GWT 1.5
(using links rather than a combo box though)

> So, I was thinking maybe it's feasible in GWT and I might have missed
> it in the documentation. Does anyone know how it can be done?

Someone already tried doing "truly dynamic I18N":
http://canoo.com/blog/2007/04/18/building-a-regular-website-with-the-google-web-toolkit-part-ii/
Reply all
Reply to author
Forward
0 new messages