Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.0.5 for Windows
  Go To Table Of Contents
Go To Index


28 JSR 238: Mobile Internationalization API (MIA)

JSR 238, the Mobile Internationalization API, is designed for applications that are to be displayed in multiple languages and used in multiple countries. The combination of country (or region) and language is a locale.

The central concept of JSR 238 is a resource, which is a string, image, or other object that is suitable for a particular locale. For example, an application that is to be distributed in Europe might include resources for Italian-speaking people living in Italy, Italian-speaking people living in Switzerland, Spanish-speaking people living in Spain and so on.

Resources are stored in files in a format defined in JSR 238. The resource files are bundled as part of the MIDlet suite JAR file. The Java ME SDK provides a resource manager that simplifies the job of creating and maintaining resource files.

28.1 Setting the Emulator's Locale

Alternatively, while the emulator is running, select Application > Change Locale and type in the locale you want to use.

You can change an emulator's locale from the Device Selector.

  1. Right-click on a device and choose Properties.

  2. In the Properties window, find the Locale property and click ... to open the Locale window.

  3. Select the locale from the dropdown list.

28.2 Using the Resource Manager

To launch the resource manager, select a project, then choose Tools > Internationalization > Java ME Internationalization Resources Manager.

All the resources for the selected project are displayed in the Resource Manager. See the sample project i18nDemo described in Section 28.3, "Running i18nDemo".

See also: Section 28.2.1, "Working With Locales" and Section 28.2.2, "Working With Resource Files".

28.2.1 Working With Locales

Locales are represented as folders under the top-level global node. The locale directories contain resource files which, in turn, hold the actual resources that can be used by the application.

Locales are represented by standard language and country codes as described in the MIDP 2.0 specification. For example, pt-BR represents Portuguese-speaking people living in Brazil.

  • To add a locale, right-click on the top-level global node and choose Add Locale. Choose the locale from the combo box, or type it directly, and click OK.

  • To rename a locale, right-click the locale directory and choose Rename.

  • To remove a locale and all its contained resource files, right-click the locale directory and choose Delete.

28.2.2 Working With Resource Files

Resource files can be global (at the top level) or specific to a locale.

  • To create a new global resource file, right-click the top-level global directory and choose Add new resource file. Choose a name for the file.

  • To rename a resource file, right-click the file and choose Rename.

  • You can copy, cut, and paste entire resource files. Right-click a file and choose Copy or Cut. Then right-click the locale directory (or the top-level global) and choose Paste.

  • To remove a resource file, right-click the file and choose Delete.

28.2.3 Working With Resources

Click on a resource file to display its contents.

  • To add an image or another type of binary data, click the Add button.

  • To edit a resource, double-click in the resource field.

    • For strings you can edit an existing value.

    • Double-clicking a binary file opens a file chooser.

28.3 Running i18nDemo

This MIDlet suite demonstrates the JSR 238 Mobile Internationalization API. The MIDlets String Comparator and Formatter show how to sort strings and display numbers appropriately for different locales. The third MIDlet, MicroLexicon, is a small phrase translator that comes in handy if you need to ask for a beer in Prague, Herzliya, Beijing, Milan, or several other locations.


The default fonts for the Java ME SDK do not support Chinese and Japanese. To use these languages, follow these steps before running this demo: 1. Install a True Type font that supports Chinese or Japanese. 2. Modify installdir\toolkit-lib\devices\skin-directory\conf\ to specify that font.

To run a MIDlet, highlight the MIDlet, then use the Launch soft button to run the MIDlet.

String Comparator

The String Comparator MIDlet demonstrates how strings (city names) are sorted differently depending on locale. Launch the MIDlet. Use the Menu soft button to view the menu. Click or Type 2 to select Sort - default, and the list is sorted alphabetically. Click or Type 3 to select Sort - slovak. It's easy to see the difference in the cities that begin with the letter Z, with and without the mark on top. Click Exit to return to the list of MIDlets.


The second MIDlet, Formatter, simply displays times and numbers formatted for different locales. Click next to view all four screens. Click Exit to return to the list of MIDlets.


The final MIDlet, MicroLexicon, translates phrases from one language to another language. To set the source language, follow the steps in Section 28.1, "Setting the Emulator's Locale".

To select the target language from the list, use the navigation arrows to highlight Choose Language. Click the Select button to view the language drop down. Use the navigation arrows to choose a language and then click Select. Click the Next soft button.

MicroLexicon displays a list of phrases. Highlight one and press the Select button on the emulator.

MicroLexicon displays the flag of the target language and the translated phrase.

MicroLexicon is powered by MIDlet resources. To understand how you can use the Java ME SDK to localize an application, choose Tools > Internationalization > Java ME Internationalization Resources Manager. All the resources, both text and images, used by MicroLexicon, appear. You can edit the resources and run MicroLexicon again to see what happens.

Description of i18n-resources-manager.gif follows
Description of the illustration i18n-resources-manager.gif

To practice creating and editing resources, see Section 28.2.2, "Working With Resource Files".

The resources are stored in the project's JAR file.