Previous | Next | Trail Map | Internationalization | A Quick Example

Creating the ResourceBundle

ResourceBundle objects contain locale-specific objects. You use ResourceBundle objects to isolate locale-sensitive data, such as translatable text. In our sample program, the ResourceBundle is backed by the properties files which contain the message text we want to display.

Our ResourceBundle is created as follows:

message = ResourceBundle.getBundle("MessagesBundle",currentLocale)
The arguments passed to the getBundle method identify which properties file we want to access. The first argument, MessagesBundle, refers to this family of properties files:
MessagesBundle_en_US.properties
MessagesBundle_fr_FR.properties
MessagesBundle_de_DE.properties
The Locale, which is the second argument of getBundle, specifies which of the MessagesBundle files is chosen. When the Locale was created, the language code and country code were passed to its constructor. Note that the language and country codes follow MessagesBundle in the names of the property files.

Now, all we have to do is get the translated messages from the ResourceBundle.


Previous | Next | Trail Map | Internationalization | A Quick Example