Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.ResourceBundle

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic