Resource Bundle
to achieve Internationalization1 Labels
User interface locale-specific labels are stored in Resource Bundle. A resource bundle is a Java .properties file that contains locale-specific data. It is a way of internationalising a Java application by making the code locale-independent.
Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a String for example, your program can load it from the resource bundle that is appropriate for the current user's locale. In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles.
In this project, Resourse Bundles are located in path:
src/main/resources/deister/axional/frontend/resources/app/labels/labels_XX.properties
where XX are the current supported locales: En, Es, Ca
1.1 Java properties files
.properties is a file extension for plain text files mainly used in Java related technologies to store the configurable parameters of an application. Each parameter is stored as a pair of strings, one storing the name of the parameter (called the key), and the other storing the value.
SEARCH_ITEM=Search article CHECKOUT=Checkout UPDATE=Update LOGOUT=Logout PURCHASE_SUCCESS_HEADER=Perfect
1.2 How a ResourceBundle is Related to a Locale
Conceptually each ResourceBundle is a set of related subclasses that share the same base name. The list that follows shows a set of related subclasses. ButtonLabel is the base name. The characters following the base name indicate the language code, country code, and variant of a Locale. labels_en_GB, for example, matches the Locale specified by the language code for English (en) and the country code for Great Britain (GB).
labels labels_de labels_en_GB labels_fr_CA_UNIX
To select the appropriate ResourceBundle, invoke the ResourceBundle.getBundle method. The following example selects the labels ResourceBundle for the Locale that matches the French language, the country of Canada, and the UNIX platform.
Locale currentLocale = new Locale("fr", "CA", "UNIX"); ResourceBundle introLabels = ResourceBundle.getBundle( "labels", currentLocale);
If a ResourceBundle class for the specified Locale does not exist, getBundle tries to find the closest match. For example, if labels_fr_CA_UNIX is the desired class and the default Locale is en_US, getBundle will look for classes in the following order:
labels_fr_CA_UNIX labels_fr_CA labels_fr labels_en_US labels_en labels
Note that getBundle looks for classes based on the default Locale before it selects the base class (labels). If getBundle fails to find a match in the preceding list of classes, it throws a MissingResourceException. To avoid throwing this exception, you should always provide a base class with no suffixes.