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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
fdu4
Posts: 11
Registered: ‎12-12-2008

How do I properly adopt my application to the language settings change

Hi, I have wrote an application, which supports two languages: German and English. I have an problem with the next scenario:

 

1) the device language is set to English.

2) my application is open.

3) I minimize the application, go to the options->language and change it to German

4) I save changes and switch back to my application

5) the localized contents are shown in English anyway

6) first as I switch to another screen of the application, the localized contents are shown in German, as intended

7) after that all localized contents everywhere in the application are shown in German

 

Interesting is, that if I open an (custom) menu before I minimize the application in 3), the content of this menu is updated and is shown in German already in 5)

 

The question is: should I override UIApplication.activate() and try to detect the language setting change there and reopen the screen if the language changed or is there an more simple solution to this issue?

Please use plain text.
New Developer
fdu4
Posts: 11
Registered: ‎12-12-2008

Re: How do I properly adopt my application to the language settings change

OK, this solution works:

 

public class MainController extends UiApplication{ private Locale currentLocale = Locale.getDefaultForSystem(); public void activate(){ if (currentLocale != Locale.getDefaultForSystem()) { currentLocale = Locale.getDefaultForSystem(); /* here I have the code, refreshing the active screen */ } } }

 

 any better ideas anyone?

 

Please use plain text.
Developer
simon_hain
Posts: 13,774
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: How do I properly adopt my application to the language settings change

it is a simple solution and should work. maybe you should also report this as a bug to devsupport@rim.com
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

Re: How do I properly adopt my application to the language settings change

The language change won't be shown within your application until the screen is redrawn.  This is what you are seeing in the menu.  By changing the screen within your application you are "redrawing" the new/old screen.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
almeida
Posts: 91
Registered: ‎02-04-2009

Re: How do I properly adopt my application to the language settings change

Some UI objects support localization by default (e.g., the MenuItem constructor and the setTitle method of MainScreen can take a bundle and a resource id).  Many of the other UI elements don't support localization, but you can do it yourself without much effort.

 

public class MyScreen extends MainScreen {

private ButtonField button = new ButtonField();

 

public MyScreen() {

add(button);

}

 

protected void onDisplay() {

super.onDisplay();

update();

}

 

protected void onExposed() {

super.onExposed();

update();

}

 

private void update() {

button.setLabel(bundle.getString(BUTTON_NAME));

}

}

 

When your screen first gets pushed onto the stack (onDisplay) or when it gets redisplayed (onExposed), the update method will reset the label for the button.

 

You can also subclass the fields you use and implement the same three functions on the field.

Please use plain text.