Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

Localization of menu items

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_ALARM

 

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 



"Listen carefully, I shall say this only once"
Please use plain text.
Administrator
MSohm
Posts: 14,226
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Localization of menu items

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?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Localization of menu items

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 :smileysad:

 

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).



"Listen carefully, I shall say this only once"
Please use plain text.
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Localization of menu items

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. 



"Listen carefully, I shall say this only once"
Please use plain text.
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Localization of menu items

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. 



"Listen carefully, I shall say this only once"
Please use plain text.
Administrator
MSohm
Posts: 14,226
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Localization of menu items


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?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Localization of menu items

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. 

 



"Listen carefully, I shall say this only once"
Please use plain text.
Administrator
MSohm
Posts: 14,226
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Localization of menu items

There isn't an BlackBerry API to do this directly.  You could use Locale.getDefaultForSystem() to get the current active local setting on the BlackBerry.  This could eliminate some of the string matching you have to do (only search with the current language).
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
myraddin
Posts: 405
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Localization of menu items

Great.

Thank you for the tip :smileyhappy: 



"Listen carefully, I shall say this only once"
Please use plain text.
New Developer
eDip
Posts: 11
Registered: ‎08-07-2008
My Device: Not Specified

Re: Localization of menu items

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 

Please use plain text.