File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Resource bundle without country? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Resource bundle without country?" Watch "Resource bundle without country?" New topic

Resource bundle without country?

David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
Is it possible to use a file named wiht only the language?
I would hope this would cover all Spanish languages, regardless of country.
The issue we're having is replicating all of the "es" translated files to the multiple countries we'd like to support.
My question is thus:
If we leave off the Country from the filename, does it still get picked up, if the user's language is Spanish, using the syntax above?
girish rateshwar
Ranch Hand

Joined: Mar 04, 2001
Posts: 99
Well below is wat i found in the java docs.

Appending the locale name to the base name of the bundle effectively links the bundle's usage to a specific locale. When you ask for the bundle using ResourcBundle.getBundle("MyResource"), the getBundle method appends the default locale identifier to the base name and loads the appropriate bundle.
The getBundle method provides a graceful degradation algorithm that attempts to find the nearest matched bundle in cases where the specified bundle can't be found or doesn't exist.

In the following search, each element of the search name is separated with an '_' (UNDERSCORE) character. The algorithm searches for bundle names in the following order:
<baseclass>+<specific language>+
<specific country>+<specific variant>
<baseclass>+<specific language>+
<specific country>
<baseclass>+<specific language>
<baseclass>+<default language>+
<default country>+<default variant>
<baseclass>+<default language>+
<default country>
<baseclass>+<default language>
If no bundle is found, getBundle throws a MissingResourceException.

I agree. Here's the link:
subject: Resource bundle without country?
It's not a secret anymore!