Create message catalogs

Identify 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.

  1. 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 structure

    key = string associated with the key
    

  2. 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."

 Usage scenario

The following English catalog (BankingResources_en.properties) supports the labels for the list and its two list items

accountString = Accounts
savingsString = Savings
checkingString = Checking

The corresponding German catalog (BankingResources_de.properties) supports the labels as follows

accountString = Konten
savingsString = Sparkonto
checkingString = Girokonto

Write code to compose the language-specific strings.

 

See Also

Internationalization: Resources for learning