Hello
I am using Resource Bundles in a Swing application. I have a method
that requests the appropriate resource bundle based on the current
locale.
public ResourceBundle getPPBundle()
{
logger.log(Level.INFO, "locale is " + loc.toString());
PPBundle = ResourceBundle.getBundle("PP", loc);
logger.log(Level.INFO, "locale is " +
PPBundle.getLocale().toString());
return PPBundle;
}
As shown above : loc is of type Locale and when I print its value, it
shows "ar" in this case. I have 2 properties files : PP.properties(the
default) and PP_ar.properties(the arabic properties file). However when
I execute the code, the ResourceBundle locale is blank ("") when
printed and the string returned is in the default language instead of
in Arabic.
The same code worked some time back, and I can't seem to figure out
what has changed to change the behavior.
Can someone think of a reason??
Thanks
Swetha
Thomas Weidenfeller - 01 Feb 2006 15:40 GMT
> As shown above : loc is of type Locale and when I print its value, it
> shows "ar" in this case. I have 2 properties files : PP.properties(the
> default) and PP_ar.properties(the arabic properties file).
They have to be at the right location in the class path, since
getBundle() uses ClassLoader.getResource() to locate the file. See the
API documentation of getResource() for how this is done.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Roedy Green - 01 Feb 2006 21:07 GMT
>The same code worked some time back, and I can't seem to figure out
>what has changed to change the behavior.
The usual problem is not having the resource inside the proper package
tree in the jar or getting confused about lead dots and slashes and
level of qualification. Everything is case sensitive.
see http://mindprod.com/jgloss/resource.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Swetha - 02 Feb 2006 10:37 GMT
Thanks for the suggestions.
It turned out that there was a manual error in one of the unicode
values and so the file was viewed as corrupt and the default properties
file was being returned.
Swetha