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

Creating the Properties Files

A properties files stores information about the characteristics of a program or environment. A properties file is in plain text format. You can create it with just about any text editor.

In our example, the properties files store the translatable text of the messages we wish to display. Before our program was internationalized, the English version of this text was hardcoded in the System.out.println statements. Our default properties file, which is called MessagesBundle.properties, contains the following lines:

greetings = Hello
farewell = Goodbye
inquiry = How are you?
Now that the messages are in a properties file, they can be translated into various languages. No changes to the source code are required. Our French translator has created a properties file called MessagesBundle_fr_FR.properties, which contains these lines:
greetings = Bonjour.
farewell = Au revoir.
inquiry = Comment allez-vous?
Notice that the values to the right side of the equal sign have been translated, but that the keys on the left side have not been changed. These keys must not change, because they will be referenced when your program fetches the translated text.

The name of the properties file is important. The name of the MessagesBundle_fr_FR.properties file contains the fr language code and the FR country code. These codes are also used when creating a Locale object.


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