Skip to main content

JSF 2 | localization question

No replies
Amgad
Offline
Joined: 2013-04-22
Points: 0

I am trying to use localization with JSF 2. so i used javax.faces.resource.localePrefix property in message bundle.
All works fine and javax.faces.resource.localePrefix is read based on the client's browser locale.
but when i tried to change the locale upon user's choice(choose between languages), javax.faces.resource.localePrefix is still read based on browser's locale.
i used the following techniques to change the locale on runtime, assuming that user's browser locale in "ar" and i want to change into "en":
1-
2- used preRenderView listener to change the locale using:
FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.ENGLISH);
3- used phase listener and on RESTORE_VIEW phase i have done the following:
FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.ENGLISH);

all my retrials have failed, i suspect this to be and issue with JSF2.
your help is highly appreciated.
thanks in advance.

regards,
Amgad