Today I will explain a little trick I have been using to localize the name of my Android apps in the BlackBerry system menu. I have not found any documentation for this on Google, so I’ll explain my solution.
When I started porting some of my apps to BlackBerry the first thing I observed was that the application name was not localizable. Of course, it is within the Android code, but the name shown on the BlackBerry menu (at least on the Playbook) is always the default one (in English). If your app has a custom name that’s not a problem, but when the app name is translatable, it looks just wrong.
So, I explored a little bit. I searched in message boards and found someone that was talking about “.bbr” files (this was a long time ago and I don’t have the link right now). I started searching and ended up finding a part of documentation that someone posted in PasteBin (maybe some part of BlackBerry’s or QNX documentation? I don’t know!). In it, it described the parameters which can be specified on the MANIFEST.MF file, which identifies and describes your BlackBerry app.
So, after some tests (and looking at the decompiled code of the BlackBerry Android Tools), I figured out that I just had to specify a parameter with the supported languages and get it included on the manifest file, so I did that (I will explain the full process further on).
But after compiling this into a BAR file, the system complained that there was no MANIFEST_ca.bbr, MANIFEST_en.bbr or MANIFEST_es.bbr file. I tried to get it recognized by Eclipse, but it wouldn’t. I tried adding it manually to the BAR file, but obviously then it complained because it was not properly signed.
So I found out an alternative. It’s a little crappy, but it works: running a shell script that injects the .bbr files onto the temporary files created during the BAR building process (a directory on /tmp/apk2bar[…]/).
So, let’s explain all the necessary steps.
1. Create a MANIFEST.MF file inside your project, on the following path: assets/blackberry/MANIFEST.MF, with at least the following code:
Package-Locale: [your language codes, separated by commas, example: en,es,ca]
2. Make sure that your manifest gets combined into the automatically generated manifest: right-click on your project in Eclipse, select Properties, then BlackBerry, and set “Custom BAR manifest” to “Add custom values (merge)”. Then save the changes.
3. Create a directory with all your .bbr files and this script (add_localization.sh). Each .bbr filename must be “MANIFEST_[language code].bbr”, and must contain the following parameters:
Entry-Point-Localization: [your default app name]
Entry-Point-Name: [your localized app name]
For example, in my case, MANIFEST_ca.bbr would have:
Entry-Point-Localization: Next bus Barcelona
Entry-Point-Name: Proper bus Barcelona
4. When you are ready to build your BAR file, simply run the add_localization.sh script. When execution starts it will start checking for when the apk2bar directory gets created, and will then copy the .bbr files into it.
5. Build the BAR file. If all went well, the script should output “Files copied into temporary directory!”. Your BAR file should contain all the .bbr files.
Please keep in mind that this script does no error checking, and can have concurrency problems, so you should always check your generated BAR files to see if all the .bbr files got included into it.
Now you can run your app and the correct name according to the system language will be shown!