Language setting

Former Member
Former Member
How can I access to the language from device settings?

Thanks for all and your help
  • How can I access to the language from device settings?

    Thanks for all and your help


    I don't think there is a specific method to access the device language, since the language stuff is automatically handled through the use of string resources separated out by language. What you might consider doing is putting a "lang" string in each language resource folder you are supporting and then you can check the value; I do something similar right now so as to access the device model.

    <resources>
    <strings>
    <string id="UserLanguage">eng</string>
    </strings>
    </resources>


    So the above XML would go in //<PROJECT_HOME>/resources-eng/language.xml and then you could create similar files in any other language-based resources folders. Then you could set a language variable when your app starts up.

    var language = Ui.loadResource(Rez.Strings.UserLanguage);
  • Former Member
    Former Member over 8 years ago
    Thanks for your help
  • Former Member
    Former Member over 8 years ago
    How to use

    I don't think there is a specific method to access the device language, since the language stuff is automatically handled through the use of string resources separated out by language. What you might consider doing is putting a "lang" string in each language resource folder you are supporting and then you can check the value; I do something similar right now so as to access the device model.

    <resources>
    <strings>
    <string id="UserLanguage">eng</string>
    </strings>
    </resources>


    So the above XML would go in //<PROJECT_HOME>/resources-eng/language.xml and then you could create similar files in any other language-based resources folders. Then you could set a language variable when your app starts up.

    var language = Ui.loadResource(Rez.Strings.UserLanguage);


    How you use that variable? Because I do an if with the variable language and the simulator clear the display of the device

    Thanks for your help
  • How you use that variable? Because I do an if with the variable language and the simulator clear the display of the device

    Thanks for your help


    Hmm, if the simulator is cleaning the display then that sounds like there is a runtime error -- check the console to see what the error is. Perhaps the variable is not in scope for the if statement? You should be able to just do something like this:

    if (language.equals("english")) {
    System.println("I'm English!");
    } else {
    System.println("I'm something else -- " + language);
    }
  • Former Member
    Former Member over 8 years ago
    Ok, I'll try with that code

    Thanks for your help
  • Note: In order for the above trick to work you have to list all the relevant languages in the manifest.

    For newer devices (CIQ 3.1.0) System.getDeviceSettings().systemLanguage can be used.