Java Internationalization (I18N)

Internationalization is used to be adapted to various languages and regions without engineering changes. Sometimes the term internationalization is abbreviated as i18n, because there are 18 letters between the first “i” and the last “n.”

An internationalized program has the following characteristics:

  • With the addition of localized data, the same executable can run worldwide.
  • Textual elements, such as status messages and the GUI component labels, are not hardcoded in the program. Instead they are stored outside the source code and retrieved dynamically.
  • Support for new languages does not require recompilation.
  • Culturally-dependent data, such as dates and currencies, appear in formats that conform to the end user’s region and language.
  • It can be localized quickly.

Step 1 Create Java Project

Launch Eclipse IDE; Create new Java Project by going to File -> New -> Others… -> Java Project. Choose any project name you want then click Finish.

Step 2 Create Properties Files

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

  • Right click to the project or src folder; select New -> Package;
  • Enter in Name field or any name you want;
  • Click Finish.
  • Right click to the package select New -> Others… Under General category; select File. Choose a name then click Finish.

Step 1.1

This file stores the messages in English to be displayed.

Step 1.2

This file stores the messages in French to be displayed.

Step 1.3

This file stores the messages in Deutsch (German ) to be displayed.

Step 3 Create Java Class

  • Copy the code below to clipboard;
  • Select src folder in your project; Press CTRL + V;

Eclipse IDE will automatically create package & class file with the code that’s pasted from clipboard.

Note: if you want to place your properties files in an absolute path for example C:/test; you can load the Resourse bundle using the following code snippet:

Run The Application

Right click to the the class; select Run As -> Java Application.