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
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel
Accepted Solution

Check the Language set in the Device

 Hi,

I want to get the language set by the user in the settings screen for my application. If he set the language as english, i have to check and display the corresponding html files in the Browser Field. For this, i have tried in the below way: 

 

if(Locale.getDefaultForSystem == Locale.LOCALE_en)

{

  // Dispaly the contents here

}

 

But it is not working. I have to check for six languages like English, French, Italian, Spanish, German and Japanese.

 

Please help.

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Check the Language set in the Device

Maybe I'm reading this incorrectly, but I don't think the code you supplied will compile.  And I think you will see your code compares a Locale object with an int, so I guess it is not surprising that it doesn't work.  I would review the API and make sure that you are using it correctly. 

Developer
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: Check the Language set in the Device

Sorry Peter. I missed the code..

Here is the code which i am executing:

 

if(Locale.getDefaultForSystem().getCode() == Locale.LOCALE_en)
        {
            Logger.out("CustomStore", "English local");
            strUrl = "local:///OTPhelp_en.html" ;
        }

Highlighted
Developer
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: Check the Language set in the Device

I got the solution..

 

the below code did the tricks :

 

if(Locale.getDefaultForSystem().getLanguage().equalsIgnoreCase("en"))
        {
            Logger.out("CustomStore", "English local");
            strUrl = "local:///OTPhelp_en.html" ;
        }