Adding Localization Support to a MIDP Application

See Also

Adding Localization support to your MIDlet is a four-step process:

  1. Create the java classes that initialize the localization support and message property files. The messaged property stores the localization keys and their values.
  2. Change the Internationalization String and Search formats.
  3. Add the localization keys and their values to the properties file.
  4. Add getMessage() methods to your MIDlet to identify elements to be localized.

To create the initial class and properties files:

  1. Select a Java ME MIDP project node (project node icon) and choose New > File/Folder.
  2. Under Categories, select MIDP. Under File Types, select Localization Support Class. Click Next.
  3. Enter the values required for the New Localization Support Class wizard.
    The wizard creates two files:

To Change the String and Search formats:

  1. Choose Tools > Options from the Main Menu.
  2. Click the Advanced Options button.
  3. Choose the Internationalization node in the Options menu tree.
  4. In the properties window:

To add localization keys and their values:

  1. Navigate to the .properties file and double-click on its node.
    This opens the file in the Source Editor.
  2. Use the Source Editor to add your keys and their values into the .properties file.
    For example, LAB_NextButton = Next.

To add code to initiate localization:

  1. Enter the following string in your MIDlet wherever you want a key localized:
    LocalizationSupport.getMessage("Key");
    For example, LocalizationSupport.getMessage("LAB_NextButton");

After all the strings have been added to the messages.properties file, do the following to add values for each new locale:

  1. Right-click on the file node in the Projects view and choose Add Locale.
  2. Choose a locale you want to support from the Predefined Locales list box, or use the combo boxes at the top of the form to define a new locale.
  3. Expand the message.properties node in the Projects view, and double-click on the newly-added locale.
  4. Translate all properties into the appropriate language.

The mobile application will use the microedition.locale attribute to determine which version of the messages.properties file should be used.

See Also
About Localization

Legal Notices