10-17-2008 08:27 AM
Hi all.
I know how to localize my menus, but what about this scenario:
1) I create an app in locale A (where A is not part of the supported locale set)
2) I would like to insert a menu item to the native menu of (for example) ApplicationMenuItemRepository.MENUITEM_AL
Now. I would like to now the locale of the "Change Date/Time" menu item string.
Basically, I need to be sure that exactly "Change Date/Time" menu item is present in the MenuItem list but I cannot rely on the string itself (or can I?)
So is there any MenuItem ID (of the native menus) that the bb device uses to retreive a translation from it's resources which I could use so I don't have to depend on the locale?
(I know I could store the string "Change Date/Time" in every supported language (somewhere around 20 as I have counted from the bb JDE 4.5.0 API docs) and then try to match, but what if bb starts supporting more languages ?
Thanks
Solved! Go to Solution.
10-17-2008 01:45 PM
I'm not sure what you are asking here. Are you trying to pull strings out of the menu of a BlackBerry application? If so, this would not be supported.
Or are you trying to support additional locals beyond what are present on the BlackBerry handheld?
10-20-2008 03:29 AM
Hi. No. I am just trying to compare MenuItem.toString().equals("Something").
the problem is that "Something" will not match if the BB device changes language setting ![]()
That's whay I need to find a way to find out either:
a) the current locale set for bb device in general (or just for this specific menu) or
b) some kind of menuItem ID that the BB localization system uses for retrieving strings from its language database.
That way I can always use just one language because I could (if it is possible) match the given menu item ID with (for instance) english string in the localization db of bb device.
Reading through the docs I didn't find any mention of this so I doubt I will be able to do this, but In that case a) is my method of choice.
So the real question is:
Does every bb device have a predefined locale set (somewhere around 20 of them are mentioned in the API docs) and how can I determine which one is used for the given Menu (or MenuItem).
10-20-2008 03:34 AM
Ah, yes.
The menu I am talking about is one of the native menus.
So, basically I need to find out which locale is currently set in general because the language setting of the bb device might not have an impact on third party software but native menus will definitely be affected.
1) Am I right?
2) How can I find out current locale/language of a bb device.
Thank you for your patience.
10-20-2008 04:19 AM
Ok. I answered to the part of the question myself.
menuItem.getBundle().getLocale();
But the philosophy of generating a solution to my problem (explained in posts 1 and 3) is still in question.
10-20-2008 10:41 AM
But the philosophy of generating a solution to my problem (explained in posts 1 and 3) is still in question.
Can you elaborate on what you are looking for here?
10-21-2008 03:37 AM
Certainly.
I need to find a specific MenuItem from one of the native menus (for instance: PhoneLog).
Lets call it menuItem.
1) I access the menu.
2) I read through the list of menu items.
3) I am searching for the right MenuItem: if(menuItem.toString().equals("Help"));
Now, the problem is that the third step searches for the fixed string.
Unfortunately, if User changes the language that string changes (i.e. to "Hilfe")
Now I am trying to find a way to always be sure I get the right menu item.
As I already mentioned, I could try to match to every translation of the word "Help" but that seems tricky since I need to check this for every MenuItem :-( (so it's average complexitiy is o(n*m/2) (where n is number of bb supported languages and m is number of specific menu items)
Unfortunately the trick: menuItem.getBundle().getLocale(); didn't work. I got a null value ;-(
That's why I started searching for some kind of MenuItem index that bb device itself uses for translation.
Hope I was clear enough.
Thank you for the help so far.
10-21-2008 10:08 AM
10-22-2008 02:38 AM
Great.
Thank you for the tip
10-22-2008 03:49 AM
Hi,
You may try this:
1. Get the locale of the system(Blackberry).
2. If the locale is not English, set it as English.
3. Compare the menu item string (e.g. "Help") from and find the menu item index.
4. Change the locale back to the original(old) locale.
5. Remove the menu item at specified index from the menu.
Regards