Resouce Bundle - strange behavior or my mistake??

S

Swetha

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
 
T

Thomas Weidenfeller

Swetha said:
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
 
R

Roedy Green

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
 
S

Swetha

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top