|
|
A Quick Example |
ResourceBundleobjects contain locale-specific objects. You useResourceBundleobjects to isolate locale-sensitive data, such as translatable text. In our sample program, theResourceBundleis backed by the properties files which contain the message text we want to display.Our
ResourceBundleis created as follows:The arguments passed to themessage = ResourceBundle.getBundle("MessagesBundle",currentLocale)getBundlemethod identify which properties file we want to access. The first argument,MessagesBundle, refers to this family of properties files:TheMessagesBundle_en_US.properties MessagesBundle_fr_FR.properties MessagesBundle_de_DE.propertiesLocale, which is the second argument ofgetBundle, specifies which of theMessagesBundlefiles is chosen. When theLocalewas created, the language code and country code were passed to its constructor. Note that the language and country codes followMessagesBundlein the names of the property files.Now, all we have to do is get the translated messages from the
ResourceBundle.
|
|
A Quick Example |