Add localization support to a MIDlet

In this section, you will learn how to use the localization support available in MTJ.

Enabling localization support

  1. In the Package Explorer view, right click the Project folder and select the Mobile tools for java > Enable Localization option.

    Enable Localization

  2. On the Localization wizard, select the appropriate information on where to generate the localization *.properties files and the package where Localization API classes will must be generated.

    Localization Wizard


If you have completed the above steps, the Package Explorer view will now contain 3 new files:


The new Java ME project

Adding new locales and entries

  1. In the Package Explorer view, double click the Localization Data file to open the Localization Data editor.
  2. On the Localization Data Section, click on the Add Locale button. This will add a new locale (The default locale is en-US).

    Localization Data Editor

  3. Save the Localization Data file.

    The L10nConstants.java file will be recreated with a new constant mapping the new added locale.


    L10nConstants.java File

    The file messages_en-US.properties will be created in the folder you specified in the Localization Wizard.


    messages_en-US.properties File


  4. Now, click on the Add Entry button. This will add a new entry to the selected Locale.

    Localization Data Editor

  5. Save the Localization Data file.

    The L10nConstants.java file will be recreated with a new constant mapping the new locale entry.


    L10nConstants.java File

    The file messages_en-US.properties will be will be update with the value you added through the editor.


    messages_en-US.properties File



Using the Localization API