11-01-2009 03:19 AM
Hello,
I'm trying to implement in my application a multi-language GUI and in order to do so I need to set the input language programmatically, I tried to use Locale.setDefault(MyLang) which suppose to affect only my application GUI but it doesn't do anything except for changing the menu options to the language I selected, but the input is still in the original language of the phone.
Does anyone have an idea?
Thanks.
Solved! Go to Solution.
11-01-2009 05:09 AM
I found that a statement like the following will change languages for me:
Locale.setDefault(Locale.get(Locale.LOCALE_de, null));
I have set up my resources to match. This works regardless of the default setting of the phone:
I'm not sure I understand:
"but the input is still in the original language of the phone"
Can you give an example?
11-01-2009 06:13 AM
Hi,
I tried the same API as you mentioned in your post and i got only "half" solution:
I can see that the default Menu options is now shown in the language i wanted but when i type text in a text field
its still in english (the original language i wanted to change)
11-01-2009 07:59 AM
I restart the app when I change Language, Don't know whether that makes any difference, but I guess if you don't create a new Screen, you won't update the Labels etc. If you restart the app (i.e. recreate all the Screens) does it work for you?
11-01-2009 08:34 AM
If you mean I should close the screen and then recreate it the answer is no, i didn't do it so i'll have to check again and update you, thanks.
11-03-2009 02:37 AM
Hello Peter,
I've tried several ways and i still get the same result: The input language in my edit field is the original language of the phone and in order to change it i need to press the menu button and select the option "Switch Input Language"
however the Menu is displayed in the correct language i set.
I've attached a code snippets hoping it could help:
public class langTest extends UiApplication {
private TestMainScreen m_MainScreen;
private EditField m_textField;
langTest()
{
Locale.setDefault(Locale.get(Locale.LOCALE_es));
m_MainScreen = new TestMainScreen();
pushScreen(m_MainScreen);
}
public static void main(String[] args)
{
langTest alangTest = new langTest();
alangTest.enterEventDispatcher();
}
private final class TestMainScreen extends MainScreen {
TestMainScreen()
{
m_textField = new EditField(Field.FOCUSABLE | Field.USE_ALL_WIDTH) {
protected boolean keyChar(char key, int status, int time)
{
System.out.println("Key: " + key);
System.out.println("status: " + status);
return super.keyChar(key, status, time);
}
};
add(m_textField);
//some code
...
}
}
}
Thanks.
11-04-2009 08:08 AM
Anyone?
11-04-2009 08:38 AM
Apologies, been distracted and am busy today. Perhaps later.
But if someone else would like to have a look at this, please do....
Just one question, what is an easy way to confirm the input language. maybe in my app I have got this wrong!
11-05-2009 09:40 AM
Hi,
Finally i did the following and its working:
I've set the setDefaultInputForSystem to the locale i needed and it worked, the input language is the one i wanted
and it didn't affect the rest of the applications.
11-11-2012 01:56 PM
hey
@robybd
i have the same issue
how to use this setDefaultInputForSystem()