Describe how java localizer works with Resource Bundles.
Localizer is the most popular way for localizing a Java application. The localizable information is persisted in “ .properties “ files. The localizer ‘Lingobit’ translates the required files into another language. For instance, the file MyResources.properties would be translated into the following files:
- MyResources_DE.properties for German,
- MyResources_FR.properties for French
- MyResources_ES.properties for Spanish.
The resource bundle file MyResources.properties will have the following statements:
#MyResources.properties file – a comment in properties file starts with #
CancelKey=CancelThe code for loading the string for a specific code is as follows:
ResourceBundle myResources = ResourceBundle.getBundle("MyResources", currentLocale);
button1 = new Button(myResources.getString("OkKey"));
button2 = new Button(myResources.getString("CancelKey"));