This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Allow User to Select a Locale

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, ActionServlet with check the 'Accept-Language' header of the http request message and from it determines automatically the locale of the client browser. Struts will then select the appropriate message resource from this auto obtained locale.

However, this approach requires the browser config'ed with the proper accept-language header (for IE tool->option->language). Inside of this, I want to put the locale selection in a JSP page and ask the user to select it explicitly.

My problem is how I can tell the ActionServlet what locale the user has selected in my JSP page. Since most of the locale selection is done automatically, I do not quite understand how Struts is handling this and the way to override it.

Could anyone get me some advice. Thx
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Locale can be changed manually using Action's setLocale(HttpServletRequest, Locale) method.

Just use the lowercase two-letter ISO-639 language code and the uppercase two-letter ISO-3166 country code to build a locale then use the setter to modify the user's current selected Locale into it's Session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic