In GWT I have to specify what locales are supported in my application. The code get compiled in various files, one for each locale (beside other versions), but I have to give my clients one only URL. This URL is supposed to be a page that should be displayed according to the locale preferred by the browser. I dont't want to have an HTTP parameter for the locale since I want to forse the locale preferred by the browser. How can this be coded in GWT?
Should I try to to this using apache rewrite rules? I thied it, but I think I cannot access such parameter easely in a rewrite rule.
Thanks a lot, Giuseppe
Unless I am reading the documentation incorrectly I don't think you have to do anything.
GWT and Locale
The way I read it, as long as your module has added all the locale choices to it, it should be automatic?
GWT has good support for internationalization. See this link. The i18nCreator command can help you to set up the internationalization infrastructure for similar to the way projectCreator and applicationCreator set up the GWT application.
If you have static strings (i.e. Invalid Entry!) that need to be internationalized, you don't need any additional flag to i18nCreator command to create the properties files and infrastructure.
If you have strings that need to accept parameters (i.e. Hello {0}), you need to pass the -createMessages flag to i18nCreator command to create the properties files and infrastructure.
Now your module needs to include the i18n module in your MyApplication.gwt.xml:
Define a Java interface in the same package as your property files that extends Constants or Messages and defines methods (name matches the property entries) that all return string.
MyConstants.properties contains:
MyConstants.java contains:
Now to access these internationalized Strings from you application:
GWT implements the interface for you automagically.
You can get messages in a similar way.
Hopefully this can help you get started.
Check this com.google.gwt.i18n.client.LocaleInfo.getCurrentLocale()
I had the same problem as you, but as I really need to know the current locale (I'm requesting a second server for data that I want to be localizable) I found this class:
com.google.gwt.i18n.client.LocaleInfo#getCurrentLocale()
. That should give you what GWT uses currently.