In my application(GWT(EXT_GWT) + Spring) I need to set user(after login) his native language, without get params. For example: user filling his login&pass at login form and then redirecting at ready-to-work form (this form must be with native user language. Locale I get from db). My language files written at .properties files and enumerated in module.gwt.xml config.
So question is - how I can set language? Maybe with session or post params? But I don't understand how GWT before loading page choose needed locale. Some methods to set locale at gwt before page loaded?
Thanks!
I think, after receving user locale info from db you should redirect him to url such as (if he is from Russia):
http://www.example.org/myapp.html?locale=ru
For example, you can save boolen flag that app was localized in session and implement this steps:
LocaleInfo.getCurrentLocale().getLocaleName();GWT.getModuleBaseURL() ?locale=locale_value on endWindow.Location.replace(newUrl)for example localizeApp method may look like this:
void localizeApp(User user) {
if (!localized) {
String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
if (!locale.equals(user.getLocale)) {
String url = GWT.getModuleBaseURL();
String newUrl = url + "?locale="+currentLocale;
localized = true; //and save to session here
Window.Location.replace(newUrl);
}
}
}
More info abou localization in GWT you can find here Internationalizing a GWT Application and here Internationalizing a GWT Application Think It will help you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With