Java Cookbook
resource bundles
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:
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:
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