Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

struts Internationalization - problem with the locale

843840Apr 8 2010 — edited Apr 12 2010
I'm new with Java and struts and I have to make an existing application multilingual.
In my application, Struts use the correct ApplicationResources.properties file according to the locale sets in the browser.

As I know, Struts is supposed to use the
org.apache.struts.Globals.LOCALE_KEY
sets in the session to display the correct language messages in the jsp pages.

To make a test, in my action method I have put
HttpSession session = request.getSession(); 
Locale locale = new Locale( "fr", "CA" ); 
session.setAttribute(org.apache.struts.Globals.LOCALE_KEY,locale);
The preferred language in my Browser is English [en]

In my jsp page I output:
out.println("Locale is :"+request.getLocale()); 
out.println("<br>"); 
out.println("Globals.LOCALE_KEY :"+session.getAttribute(org.apache.struts.Globals.LOCALE_KEY));
and I get:
Locale is :en
Globals.LOCALE_KEY :fr_CA

The messages are still in english and I have an Application.Resources_fr.properties file. It looks like Struts doesn't use the org.apache.struts.Globals.LOCALE_KEY but always the locale sets in the browser.
Is anybody knows how to solve this problem?

Thank you in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2010
Added on Apr 8 2010
5 comments
1,335 views