wood burning stoves*
The moose likes Struts and the fly likes How to Allow User to Select a Locale Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to Allow User to Select a Locale" Watch "How to Allow User to Select a Locale" New topic
Author

How to Allow User to Select a Locale

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Aug 07, 2003
Posts: 75
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.


Franck<p>--------------------
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to Allow User to Select a Locale
 
Similar Threads
Best practice for i18n/locale selection?
Internationalization with dropdown
Struts: The Complete Reference - Internationalizaion ???
Dummy needs explanation
User to Choose Language Explicitly