The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

resource bundles

Load properties from outside the classpath

 

 Problem:

You want to locate your resource bundles outside your application classpath.

Solution:

Create an InputStream and use it to create the PropertyResourceBundle directly using the constructor.

To loop through a collection of locales and look for a matching properties file outside the classpath then extract a resource from it:

  • properties
  • resource bundles
  • resources
  • Add new comment
  • Read more

Resource Bundles

One of the first steps in internationalizing an application is th externalizing of text.  This simplifies the translation process and makes localization far easier. 
The standard way of handling resources in Java has been by the use of properties files.  A properties file is simply a text file containing key value pairs.  It is named with the syntax, name_language_country_variant.properties.  So a bundle for a Japanese bundle called errors would be titled, errors_ja.properties.
An example file might look like:

  • Java
  • rbs
  • resource bundles
  • Add new comment
  • Read more

If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.

This site is ad supported.  I hope you find something among our sponsors worth clicking. ;)

i18n search

Google
Custom Search
Syndicate content

Search

Tags in Tags

calendar date icu4j Java Locale number format numberformat parse spellout timezone transliteration transliterator
more tags

User login

  • Create new account
  • Request new password
  • java cookbook
  • about the author