Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resource bundle without country?

 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use a file named wiht only the language?
EXAMPLE:
Resource_es.properties
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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>
<baseclass>
If no bundle is found, getBundle throws a MissingResourceException.
Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic