Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

internationalization: a rock and a hard place

 
Marc Schipperheyn
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic