Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ResourceBundle not using Locale

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what I'm doing wrong - this seems very straightforward. I have simple internationalization code and I'm trying to override the Locale being used. However, using the PropertyResourceBundle.getBundle(String, Locale), the Locale seems to be ignored.

Here's the test class:


Here's the TextLabel class:


Pretty straightforward. However, the output generated is:
Locale = en_US
Bundle using
Locale = en_US
Bundle using
Locale = en_US
Bundle using fr_CA

I would expect the last one to say "Bundle using en_US". I'm running the test inside Eclipse 3.3.0 using Sun's 1.5.0.13 JVM. Any ideas why the Locale is being ignored?

Thanks in advance!
 
todd runstein
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved it. I had 2 properties files: Text_Labels.properties and Text_Labels_fr_CA.properties. Simply adding a file named Text_Labels_en.properties (which matches Text_Labels.properties) fixes the problem!
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just so that everyone gets the idea, let's slide this (probably already finished) thread over to the intermediae forum.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic