Internationalization & Localization issue
Posted
by Ahmad
on Stack Overflow
See other posts from Stack Overflow
or by Ahmad
Published on 2010-04-13T13:33:00Z
Indexed on
2010/04/13
14:23 UTC
Read the original article
Hit count: 409
Hi all,
My application supports internationalization and localization, each user can choose his preference language and the application will reflect it perfectly. the issue is when the first user selects English and the second one selects French the resource bundle for the first user will read from the French resource after refreshing his page.
I am using the following code to change between the two languages:
public void changeToEnglish()
{
FacesContext context = FacesContext.getCurrentInstance();
Locale currentLocale = context.getViewRoot().getLocale();
String locale = "en_US";
Locale newLocale = new Locale(locale);
if(!currentLocale.equals(newLocale))
context.getViewRoot().setLocale(newLocale);
}
I have the following in my faces_config.xml:
<locale-config>
<default-locale>en</default-locale>
<supported-locale>fr</supported-locale>
</locale-config>
the application respond very well to changing languages but I think when setting the locale from the FacesContext it reflects all the users locales.
Please help me on this....
© Stack Overflow or respective owner