Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Localizing your apps

You can use the BlackBerry Java Plug-in for Eclipse to localize text strings without changing the application code. The BlackBerry Java Plug-in for Eclipse provides versioning support for creating resources in different languages. You can make changes to resource values in a native language, or original locale. Translators can identify language resources that have changed and that require translation.

A ResourceBundle object stores information and resources for a locale. A ResourceBundleFamily object contains a collection of ResourceBundle objects. An application can use a ResourceBundleFamily object to display the information in a language that is specific to the locale of the BlackBerry device user.

When you compile your app , the BlackBerry Java Plug-in for Eclipse compiles each ResourceBundle object that you include with the application into a separate code .cod file. You can install the appropriate .cod files on a BlackBerry device along with the other files that the application requires.

Creating resource files

When you create a new .rrh resource header file, the BlackBerry Java Plug-in for Eclipse creates the associated .rrc resource content file. If an .rrh file already exists, the BlackBerry Java Plug-in for Eclipse creates only the new .rrc file. If an .rrh file does not already exist, the BlackBerry Java Plug-in for Eclipse creates the .rrc file and the .rrh file.

For each application that you want to localize, you must create a resource header file, a resource content file for the global locale, and a resource content file for any specific locales that you require.

File

Description

Example

Resource header file

This file defines the descriptive keys for each localized string.

During compilation, the BlackBerry Java Plug-in for Eclipse creates a resource interface automatically that uses the same name as the .rrh file with Resource appended.

AppName.rrh

Resource content file root (global) locale

This file maps numeric keys to string literals for the root (global) locale.

AppName.rrc

Resource content file (specific locales)

This file maps descriptive keys to values for the global and specific locales (language and country).

This file must have the same name as the resource header file, followed by an underscore (_) and the language code, and then, optionally, by a single underscore (_) and a country code (for example, AppName_en_GB.rrc).

Two-letter language and country codes are specified in ISO-639 and ISO-3166, respectively.

AppName_en.rrc

Create a resource file for an application

  1. On the File menu, click New > BlackBerry Resource File.
  2. In the Create a new BlackBerry Resource File dialog box, click the project folder that you want to place the resource file in.
  3. In the File name field, type the name of the .rrc file or .rrh file.
  4. Click Finish.

Specify the localization settings for a BlackBerry application project

Create the resource files that are required for localization.

  1. In the Package Explorer view, select a BlackBerry application project.
  2. Right-click the project and click Properties.
  3. In the Properties for pane, select BlackBerry Project > Application Descriptor.
  4. Click the Application tab.
  5. Specify the locale resources.
  6. Click Close.
  7. Click Yes.

Properties for localization settings

Setting

Description

Internationalized resource bundle available

Select this setting if the title and description of the application are internationalized in a resource bundle.

Resource bundle

Select the resource header file to use for the application (for example, HelloWorldRes).

Title ID

Select the resource key to use for the application title (for example, APPLICATION_TITLE). If you do not provide a resource key for the application title, the for Eclipse uses the title that is specified in the Title field.

Description ID

Select the resource key to use for the application description (for example, APPLICATION_DESCRIPTION). If you do not provide a resource key for the application description, the BlackBerry Java Plug-in for Eclipse uses the description that is specified in the Description field.

Verify the resource keys that are used in an application

  1. In the Package Explorer view, double-click an .rrh file.
  2. In the Resource Editor window, click Validate.

    If one or more resource keys are not found, a message appears indicating the resource keys that are not present.

Locate all of the Java files that use a resource key

  1. In the Package Explorer view, double-click an .rrh file.
  2. In the Resource Editor window, click a key, and click Validate.
  3. Click Yes.

If the key is found, the BlackBerry Java Plug-in for Eclipse lists all of the Java files that reference the key and the line numbers in the Java files where the key is referenced.

Specify an original locale

The original locale contains resource values in a native language. You must specify an original locale for each resource header (.rrh) file.

  1. In the Package Explorer view, double-click an .rrh file.
  2. In the Resource Editor window, click Options.
  3. In the Resource Editor Options dialog box, select Use versioning highlighting from given resource.
  4. In the locale drop-down list, click a locale (for example, en).

Mark a translation as correct or incorrect

  1. In the Package Explorer view, double-click an .rrh file.
  2. In the Resource Editor window, right-click a resource key.
  3. Perform one of the following actions:
    • To mark a translation as correct, click Mark Translation Correct.
    • To mark a translation as incorrect, click Mark Translation Incorrect.