• 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

Resource bundle without country?

 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
reply
    Bookmark Topic Watch Topic
  • New Topic