[JSF 1.2 and 2.0/Internationalization] How to propagate the Locale to the entire application

Hi,
do you know how to internationalize an application in a dynamic way in JSF 1.2 ?
I created 2 files msg_fr.properties ( language by default, french) and msg_en.properties ( english)
Then I wrote a methode changeLanguage() in a Managed Bean . This method allows me to switcher the language in the first page of the application.
This method is called in a tag <h:commandLink>
public void changeLanguage() { 
        FacesContext context = FacesContext.getCurrentInstance(); 
        // I test a parameter (currentLanguage) and I switch in consequence 
       context.getViewRoot().setLocale(Locale.ENGLISH); 
       //or    context.getViewRoot().setLocale(Locale.FRENCH); 
       context.getApplication().setDefaultLocale(context.getViewRoot().getLocale()); I have of course modified the file faces-config.xml.
This WORKS but for the current page only. The Locale is not propagated to the next pages of the application.
The Locale by default of my browser is English and so the next pages are always in English, even if i switch the first page to French.
Do you know how to propagate this Locale to all the pages of the application in JSF 1.2 ?
Also, has internationalization been improved in JSF 2.0 ?
thanks

The f:view has a 'locale' attribute. You should make use of it. Feed it with a property of a session scoped bean which you could control/change using for example some language dropdown menu or a request parameter or pathinfo. There is no need to traverse the FacesContext and UIViewRoot yourself.
For more about i18n in JSF, please consult the Sun JSF specification and the Sun Java EE tutorial.

Similar Messages

Maybe you are looking for