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
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)
Accepted Solution

Set input language

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.

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Set input language

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?

Please use plain text.
Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Set input language

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)

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Set input language

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?

Please use plain text.
Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Set input language

 

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.

 

Please use plain text.
Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Set input language

 

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.

Please use plain text.
Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Set input language

Anyone?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Set input language

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!

Please use plain text.
Developer
robybd
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Set input language

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.

Please use plain text.
Regular Contributor
amr3434
Posts: 81
Registered: ‎01-16-2012
My Device: BOLD 9650 + developer
My Carrier: Vodafone

Re: Set input language

hey
@robybd

 

i have the same issue

 

how to use  this setDefaultInputForSystem()

 

Please use plain text.