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
posted 10 years ago
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.