I know the locale specific resource bundle to be used by <bean:message key="title.something" /> is selected by ActionServlet automatically base on the 'Accept-language' header of the http request (pls correct me if not). But, what if I want to let the user to select the language explicitly in my web page? Say, I want the welcome page to allow user to click language1, language2, etc. Is there any way to force Struts to retrieve the proper resource bundle using application supplied information rather than from the http header?
Thx for any advice.
posted 10 years ago
Hi I am doing somewhat similar to this in my application. Hope this will help you. I have a jsp where i am giving the option to select the language and country for the user. When i submit the page, i will get the values in my action class and using those values i am setting the locale in session as follows session.setAttribute(Globals.LOCALE_KEY,new Locale("es","ES")); Here i have selected spanish as my language and country. Using that i am creating a locale as es_ES . Corrsponding to that i should have the property file to be loaded as fileName_es_ES.properties. So when this locale reference comes it will check whether corresponding file is available or not and will load. Refer ResourceBundle class of java.and also MessageResources class of Struts . These classes will help you and also refer internationalization part in struts.