Reputation: 136221
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?
Upvotes: 1
Views: 4739
Reputation: 76
List of ISO codes for languages
As you can see, substring the ISO 639-3 (3 letters) code does not make always the ISO 639-1 (2 letters) code. Also I do not recommend this. Choose a hashtable to get the corresponding code.
Upvotes: 3
Reputation: 38098
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.
Upvotes: 3