Troubleshooting guide

16
Localizing applications
Storing text strings in resource files
Design applications so that they are localized (adapted to specific languages and regions) without coding
changes. Instead of including textual elements in your source code, store text strings in separate resource files. In
your source code, use unique identifiers that map to the appropriate resource files.
Storing text strings in separate resource files has two benefits:
Text translation is efficient because all of the text strings for a given locale are stored in a single file, outside
your source code.
Applications can dynamically retrieve the appropriate text to display to the BlackBerry® device user, based on
the locale of the BlackBerry device user.
The BlackBerry Java™ Development Environment includes a mechanism for creating string resources. The
net.rim.device.api.i18n package includes the Localization API.
A ResourceBundle object stores the resources for a locale. A ResourceBundleFamily object contains a
collection of
ResourceBundles, which groups the resources for an application. The application can switch
languages, depending on the locale of the BlackBerry device user, without requiring new resource bundles.
Storing resources for a locale
You can use the BlackBerry® Integrated Development Environment to compile each resource bundle into a
separately compiled .cod file. You can load the appropriate .cod files onto BlackBerry devices with the .cod files
for the application. The BlackBerry IDE organizes resources in a hierarchy based on inheritance. If you do not
define a string in a locale, a string from the next closest locale is used.
Storing text strings in resource files
Storing resources for a locale
Files required for localization
Add localization support
Code sample: Storing text strings in separate resources for locales
Retrieve strings from a resource file
Code sample: Retrieving strings from a resource file
Note: MIDP applications do not support localization.