Create message catalogsIdentify strings that need to be localized. You can create a catalog as either a subclass of java.util.ResourceBundle or a Java properties file. The properties-file approach is more common, because properties files can be prepared by people without programming experience and swapped in without modifying the application code.
- For each string identified for localization, add a line to the message catalog that lists the string's key and value in the current language. In a properties file, each line has the following structurekey = string associated with the key
- Save the catalog, giving it a locale-specific name. To enable resolution to a specific properties file, the Java API specifies naming conventions for the properties files in a resource bundle as bundleName_localeID.properties. Give the set of message catalogs a collective name, for example, BankingResources. For information about locale IDs that are recognized by the Java APIs, see "Resources for learning."
The following English catalog (BankingResources_en.properties) supports the labels for the list and its two list itemsaccountString = Accounts savingsString = Savings checkingString = Checking
The corresponding German catalog (BankingResources_de.properties) supports the labels as followsaccountString = Konten savingsString = Sparkonto checkingString = Girokonto
Write code to compose the language-specific strings.
See AlsoInternationalization: Resources for learning