aspose file tools*
The moose likes Struts and the fly likes internationalization: a rock and a hard place Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "internationalization: a rock and a hard place" Watch "internationalization: a rock and a hard place" New topic
Author

internationalization: a rock and a hard place

Marc Schipperheyn
Greenhorn

Joined: Mar 15, 2005
Posts: 7
Hi,

I'm trying to implement internationalization on a site where there are multiple country databases (each country has its own database) and multiple languages (all country sites have the same GUI parameters). I have country specific validation for things like zipcodes which I store in a constants file e.g. validation-constants_NL.xml. When I create ApplicationResources_nl.properties file, it isn't loaded when I set the locale to new Locale("","NL"). I need to set this to load the proper validation file. However, when I set the locale to new Locale("nl"), my validation file isn't loaded properly. Now, I feel that when I set the locale to new Locale("","NL") it should select the language file resource based on browser settings, but it doesn't seem to want to do that. I use Struts 1.2.6. I set the Locale in a custom request processor which overrides the processLocale like so:

req.getSession().setAttribute(Globals.LOCALE_KEY, Config.COUNTRY);

where Config.COUNTRY represents the default locale.

Any ideas?

Kind regards,

Marc
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi

Yes override the processLocale method in ur custom request processor and what u need to set in that function is

session.setAttribute(Globals.LOCALE_KEY,request.getLocale());(Here instead of request.getLocale() ,u can give hardcoded Locale object also but this will remain fixed across the application)

and never call super() in this method which will invoke the base class processLocale method

This will obvioulsy get the resources.properties from the appropriate resource bindle depending on the locale .but i am not understanding what u r talking about the validations xml
Marc Schipperheyn
Greenhorn

Joined: Mar 15, 2005
Posts: 7
Hi, and thanks for the reply. If I override the locale setting in processLocales Struts will take everything from the browser settings. But how then would I make it load the validation_NL file? The validation/country setting should not be dependent on the browser settings, but selectable by the user (or hard set by me per country site).

I see the following types of language key issues when I set stuff in processLocale:
* nl : validation_NL not loaded
* NL : nl language file not loaded
* nl_NL: language file loaded and zipfile loaded, but now I have to copy the language file for each language multiple times for each country: a maintenance nightmare.

Kind regards,

Marc
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: internationalization: a rock and a hard place