I have done this by putting a unique entry into each of my properties files eg

messages.properties:     internationalisation.key=English
messages_fr.properties:  internationalisation.key=French
messages_ja.properties:  internationalisation.key=Japanese

I grab the messages for the default locale, grab the internationalisation.key and throw it into a hashmap.

Next I use Locale.getAvailableLocales() to loop through all the Locales. I load the messages for the locale and check if internationalisation.key is already in the hashmap, if not I add it.

If I loaded the Italian locale, for example, and my app didn't have the properties file defined, I would get the default (English) which is already loaded and can be ignored.

I also have a hashmap of the successful Messages with the Locale as the key so I can retrieve them late. Actually the key is a string with the language, country & variant so that I can store/read easily as a user preference eg default is 3 empty strings separated by '_' = '___', others would be 'fr__', 'ja__', 'en_US_'

Jason Lea


------------------------------------------------------------------------

Subject:
RE: internationalization
From:
COMPAGNON GUILLAUME <[EMAIL PROTECTED]>
Date:
Fri, 21 Mar 2003 11:15:49 +0100
To:
"'Struts Users Mailing List'" <[EMAIL PROTECTED]>


MessageResource works like the java.util.ResourceBundle if no properties file for italian exits (applicationResources_it.properties for example), it takes the default one (applicationResources.properties)

no exception, just a default case...

otherwise, if no default file exists ... you will have a null for the
message or a ??unknown?? (if null=false in the struts-config file)

grazie mille ...

Guillaume Compagnon


-----Message d'origine-----
De:     [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
Date:   vendredi 21 mars 2003 11:08
À: [EMAIL PROTECTED]
Objet:  internationalization

Hi i've a simple question: is possible obtain the languages supported from
application? With the MessageResources class i could obtain the message in
a
particular language, if it is supported from application. For example if
i've
the properties file for the french languages i could obtain a message in
this
language...but how i know the language supported of my application ( in
fact the
file properties that there are in my application ). Is stupid try to
obtain the
message in all language for example try to obtain the message in french
and if
exists i know that there is a file properties for french...how obtain the
list
of file properties of application?
Thank in advantage.
Alessio





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to