Resource Bundles

Reading Time: < 1 minute

Resource Bundles allows you to create localized multi language supported applications for each locale. The abstract class “java.util.ResourceBundle” offers such locale-specific resources. The abstract class is sub classed by “PropertyResourceBundle” and “ListResourceBundle”. Each of these classes have their own implementations in a application which I’ll show some examples how to.

However, there are some important facts that I’d like to point; first of all if you attempt to import a resource bundle that does not exist, then the JVM will throw a runtime exception “MissingResourceException”. Second of all the resource bundle seeks an order of a Locale for a file naming format as follows;

1.bundleName_localeLanguage_localeCountry_localeVariant
2.bundleName_localeLanguage_localeCountry
3.bundleName_localeLanguage
4.bundleName_defaultLanguage_defaultCountry_defaultVariant
5.bundleName_defaultLanguage_defaultCountry
6.bundleName_defaultLanguage
7.bundleName

Source Code: https://github.com/tugrulaslan/JavaI18NDemo