aspose file tools*
The moose likes Java in General and the fly likes java.util.ResourceBundle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.util.ResourceBundle" Watch "java.util.ResourceBundle" New topic
Author

java.util.ResourceBundle

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
hi guys
i tried to do a sample using ResourceBundle the lines below show my code


iam having two property files namely myresources_gb.properties and
myresources.properties when i change Locale to Locale.US it should fetch properties from myresources.properties if change my Locale to Locale.UK it should fetch properties from myresources_gb.properties

when i swith my Locale my program is not fetching the property from corresponding property files it always fetches from myresources.properties

please reply me where iam mistaking

looking for your replies
amir
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
Your properties file should follow this naming rule:

baseName + "_" + language + "_" + country or
baseName + "_" + language

That means, myresources_en.properties or myresources_en_UK.properties
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
thanks for your reply Lopes

but my problem still exist enven i named the files as per your reply
i think i have to made some change in the code or else if some body have sample please post me

even though both uk and us follow english i want to use differnet property file for both

if i use us and es(spanish) it works fine here i used myresources_es.properties and myresources_en.properties it mandatoy to specify language in the property file for default language also

[ April 21, 2008: Message edited by: Amirtharaj Chinnaraj ]
[ April 21, 2008: Message edited by: Amirtharaj Chinnaraj ]
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
Sorry, the right name is myresources_en_GB.properties
I tested here and it worked:

myresources.properties:


myresources_en_GB.properties:


output:

[ April 21, 2008: Message edited by: R Lopes ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.util.ResourceBundle