File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

User to Choose Language Explicitly

 
Alec Lee
Ranch Hand
Posts: 569
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
poornima balagopal
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic