File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "internationalization: a rock and a hard place" Watch "internationalization: a rock and a hard place" New topic

internationalization: a rock and a hard place

Marc Schipperheyn

Joined: Mar 15, 2005
Posts: 7

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 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,

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415

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 from the appropriate resource bindle depending on the locale .but i am not understanding what u r talking about the validations xml
Marc Schipperheyn

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,

I agree. Here's the link:
subject: internationalization: a rock and a hard place
It's not a secret anymore!