Search code examples
androidlocaleiso-639-2

Android: Get the device interface language in ISO 639 3-letters format?


I am developing an Android application for the global market, which will (hopefully!) be installed by users speaking different languages.

Since I want to adjust my interface language to the device's language, I need to acquire that language name in a convenient, standard format - preferably, ISO 639-2 3-letter format in which Hebrew is heb, English is eng and Spanish is spa.

How can I get the Android interface language in ISO 639-2 3-letter format?


Solution

  • You can use this code snippet:

    protected static String lang = Locale.getDefault().getISO3Language();//.substring(0, 2);
    

    I use the 2 chars variant, but I cut that part out, to leave you the 3 chars variant, as required.