views:

27

answers:

1

Hello :-)

My question is the following:

I got one application running with GWT. At the startup of the application, one GWTClientModule which extends AbstractGinModule or another GWTClientModule is loaded.

Based on that switch I would like to set the local. Is there a way to set the local not directly in .html by doing as follow:

<meta name="gwt:property" content="locale=fr">

but directly in one of the selected GWTClientModule?

Thank you very much for your kind assistance ;-)

A: 

You cannot do that if you use static String internationalization, since it uses deferred binding: the GWT compiler generates one JavaScript file per locale, and, when your page is loaded, the GWT bootstrap script looks for the "locale" property inside the page (or in the URL), before loading the appropriate version of the code.

Choosing the locale programmatically (inside your GWTClientModule) is impossible, since the localized version of your code is already loaded once that code executes...

If you really need to choose the locale at runtime, you might want to look into dynamic String internationalization, but it is less performant and you lose static type checking.

eneveu
Thank you for your post. I'll look in the dynamic String internationalization at first sight. Or I can replace the .properties file during the build. Anyway, thanks for your explanation :-)
AbstractMan
When you talk about replacing the .properties file during the build, I have to ask: what is your end goal? Do you simply want to compile for one specific locale?Because you can do that easily by adding the following to your Module.gwt.xml: <set-property name="locale" value="fr_FR"/>More information here: http://stackoverflow.com/questions/1745315/how-to-create-a-development-debug-and-production-setup/1749507
eneveu