Troubleshooting guide
237
16: Localizing applications
Code sample: Storing text strings in separate resources for
locales
Example: CountryInfo.java
/**
* CountryInfo.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
Add resource content files. Create resource content files in the folder where the .java file exists. For example, in the folder
that contains CountryInfo.java, create CountryInfo.rrc (root locale), CountryInfo_en.rrc
(English), and CountryInfo_fr.rrc (French).
1. On the File menu, click New.
2. Type a file name and location.
3. Click OK.
4. Click Yes.
5. Leave the file empty.
6. To add the .rrc file to the application project, right-click the .rcc file in the right pane.
7. Click Insert into project.
Add resources. 1. In the BlackBerry IDE, double-click a resource header file.
2. Add resource keys:
• To add one value per key: On the Root tab, type resource keys and values for each string
or string array in your application.
• To add multiple values per key: In the resource editor, right-click a resource and click
Convert to Multiple Values. Add one or more values to the array.
3. To specify a different text string in other locales, select the tab for a locale, such as fr for the
French language.
4. In the Value cell for the resource, type the text string for the locale. If you do not define a
value for a resource in a particular locale, the value for the root locale is used. You can type
unicode characters directly into the Value cell. Visit
http://www.unicode.org for more
information about unicode characters.
Display a localized application title on the
Home screen.
If you do not provide a resource for the application title, the application uses the value you type
in the Title field on the Application tab of the Project Properties window as the application title.
1. In the resource editor, add a resource for the application title, such as APPLICATION_TITLE.
2. Type a value for this resource in each locale that you support.
3. In the BlackBerry IDE, right-click the application project, and then click Properties.
4. On the Resources tab, select the Title Resource Available option.
5. From the Resource Bundle drop-down list, select the resource header file name to use for
this application.
6. From the Title Id drop-down list, select the resource to use for the application title, such as
APPLICATION_TITLE.
7. From the Description Id drop-down list, select a description ID.
Task Steps