How to add resource file to provide multi lingual support
To reach the widest audience for your application you want to provide support for many different languages and cultures. This process is known as internationalization. The most common way of achieving this goal is through resource files for the different target languages (or cultures).
The first step to using resources is to add the resource files to your application (of course this is for the Blackberry plugin for Eclipse).
- open the package explorer and find your source package
- from the context menu (right-click) OR file->new, select Other [you can also use ctrl-N]
- open up the blackberry folder and select ‘Blackberry Resource File’
- click next
- Select the folder where you wish to save the file. Generally you want to include it with your source code.
- type in the name of your resource file ‘applicationName.rrh’ . IMPORTANT: the file must end with rrh.
- you will see that you have two files: applicationName.rrh and applicationName.rrc. the RRH file defines the symbols for each of your strings, and the RRC contains the strings.
- add in a file for each culture that you wish to include using the format: applicationName_xxx.rrc. You must replace xxx with the culture abbreviation and you need the underscore
- You have now created your files. Click on the files and start editing to your heart content.
Some of the common cultures:
|Language||neutral culture abbreviation|
|invariant culture||This culture category is culture-insensitive. The category is to be used as essentially a default culture when consistency is desired.
One situation where this category might be desirable to use is creating a trial application with a hard-coded expiration date. Using an invariant will allow you to check for a specific date, regardless of the culture’s format, which will greatly simplify the task of comparing these dates.
The invariant culture is not based on the English language per se, but it is associated with it and bears more similarities to it than to any other identifiable culture.
|Neutral Culture||A neutral culture is associated with a language but has no relationship to countries or regions. For instance, the English spoken in England is different from that spoken in the United States. The same holds true for Spanish spoken in Mexico versus that spoken in Spain.
Although neutral cultures, like the invariant culture, might be tempting to use, they should be avoided as well, if possible, for the same reasons that invariants should be avoided. The language spoken in different countries that are covered by a neutral culture will almost certainly be different in at least a few respects. In reality, the differences will be many.
|Specific Culture||This is the most precise of the three categories and is represented by a neutral culture, a hyphen, and then a specific culture abbreviation. For instance, in the designations "en-CA" and "en-US", en represent the neutral culture (English), and CA and US represent the specific culture (Canada and the United States, respectively).|