Localization - how do I change where MessageResources gets the .properties files when localizing?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mark_Trinh
Posted On:   Monday, January 26, 2004 07:11 PM

Hi, I'm trying to localize my jsp pages and currently the struts-config.xml files has the message-resources pointing to "en_US.application". What I wanted to do was change the locale by changing the session LOCALE_KEY. By default, you must have the application_es_MX.properties file in the same directory if you want it to localize to spanish. The problem is that I wanted to have different directories for my .properties files, ie. en_US/application.properties, es_MX/application.properties, fr/application.properties, fr_CA/application.properties, etc... How do I change it so when I change the session locale, then it pulls it from those specific directories with the different application.properties in   More>>

Hi,
I'm trying to localize my jsp pages and currently the struts-config.xml files has the message-resources pointing to "en_US.application".

What I wanted to do was change the locale by changing the session LOCALE_KEY. By default, you must have the application_es_MX.properties file in the same directory if you want it to localize to spanish.


The problem is that I wanted to have different directories for my .properties files, ie. en_US/application.properties, es_MX/application.properties, fr/application.properties, fr_CA/application.properties, etc...



How do I change it so when I change the session locale, then it pulls it from those specific directories with the different application.properties inside, instead of the same directory with the locale appended to it?

Part 2:

i've also noticed that if I have just application_fr.properties that it doesn't work when you change your locale to FR. You need to have the full locale & country (i.e. fr_CA). Is there anyway java will recognize the short form?


thanks in advance,
Mark

   <<Less

Re: Localization - how do I change where MessageResources gets the .properties files when localizing?

Posted By:   Mark_Trinh  
Posted On:   Tuesday, January 27, 2004 09:28 PM

Thanks, I just recently overwrote the MessageResources class and was able to do it. I needed to do that because my localization group do all their il8n files that way and it's been like that for years now, and there's no changing them :).

Thanks for all your help!

Re: Localization - how do I change where MessageResources gets the .properties files when localizing?

Posted By:   Josh_Marquart  
Posted On:   Tuesday, January 27, 2004 01:23 PM


I hope I can answer part 1 properly.


I don't believe you can do that.
All properties files for a certain bundle



mybundle.properties
mybundle_en.properties
mybundle_en_US.properties
mybundle_en_CA.properties


all need to be in the same place.


MessageResources was written to handle reading i18n properties files in a specific manner, with the appended

_language_COUNTRY
In order to force the MessageResources Object to read files differently (as you say, every file named "mybundle.properties" under subdirectories based on language/country combinations) you'd have to write your own extension of MessageResources, which I wouldn't recommend.


I also wouldn't recommend naming different properties files the same thing with different contents. Even if they're under the proper subdirectoris, it's easier to lose track of which .properties file represents which language/country combination.

About | Sitemap | Contact