BlackBerry App Internationalization: Language, currency and address support


Did you know that you can internationalize your BlackBerry® application using the JSR 238? More specifically, you can do the following to your BlackBerry application so that your app is ready for the international market:

  • Multiple language support
  • Localization of currency
  • Localization of addresses
  • Detecting which country the user is located in (in the event that you have certain content that you only have license to serve in certain geographies)

In this blog post, we will look at the multiple language support in detail – the rest of the above topics will be covered in upcoming blog posts here on the Inside BlackBerry Developer’s Blog.

All commercial applications these days should be localized, and BlackBerry uses net.rim.device.api.i18n package to enable seamless localization.

If your application is localized, it will be displayed in the local language out of the box. So if the default locale settings on one device are set to English and French on the other, the application will be displayed in the correct language on both devices without any need for interaction from the user.

Setting up a New BlackBerry Project

This blog post assumes that you should already know how to set up and configure a new BlackBerry project in Eclipse™. If you need a reminder, refer to this link.

Here is a sample code to show how to localize a simple application:

package com.rim.samples.local;

import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.i18n.*;

public class Local extends UiApplication {
public static void main(String[] args) { Local theApp = new Local();


public Local() {
pushScreen(new LocalScreen());

final class LocalScreen extends MainScreen implements LocalDemoResource {

private static ResourceBundle _res = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
LabelField title;
RichTextField rtf;

public LocalScreen() {
title = new LabelField(_res.getString(FIELD_TITLE), LabelField.ELLIPSIS| LabelField.USE_ALL_WIDTH);
rtf = new RichTextField(_res.getString(MESSAGE));

If you read the code carefully, you will notice that our LocalScreen class implements LocalDemoResource. Also new is the ResourceBundle variable _res which is used when creating our fields. To be able to use and explain them, we will first create our resource files.

Creating resource files

To be able to localize your application, you need to create .rrc and .rrh files. It is quite easy to create these files in Eclipse. Click on File->New->BlackBerry Resource File and browse to the location of your package. You will need to name your header file here — let’s call this file LocalDemo.rrh (make sure you include the extension). Pressing Finish on this screen will now allow you to implement LocalDemoResource interface.

If you called your .rrh file “exampleResource.rrh”, then the interface name would be exampleResource. Now we need to create resource files for each language:

For default language: LocalDemo.rrc
French: LocaLDemo_fr.rrc
Spanish: LocalDemo_es.rrc.

The parts of the name _fr and _es are default endings for those languages and cannot be changed.
If you did everything correctly, you should have 4 resource files just under your file. Now we need to edit these files. Double click on the LocalDemo.rrh file — this is the one which contains all the keys. Select the ‘Add Key’ Button and add the following fields:


You do not need to enter the values on this page. When you double-click on the LocalDemo.rcc file, it will open the screen where you can fill in the values. You can access the values for French and Spanish locales by clicking on the tab on the bottom of the window (marked fr or es), or by double-clicking on the file name.

As you can see, special characters used in these languages such as ‘ó’ in word “adios” or ‘ñ’ in “Español” were used. The system will use those characters and display them when needed. You can use any Unicode characters here, which means you can support languages such as Chinese or Arabic.

And that’s it! That’s all you have to do add multiple language support to your BlackBerry application. For more info and to see a full working demo, refer to this link:

Join the conversation

Show comments Hide comments
+ -
blog comments powered by Disqus