- Home /
Two letter ISO language code for mobile devices.
I'm currently using Prime31's Etcetera for iOS to get the 2 letter ISO language code. However, Etcetera for Android does not provide such a functionality. I've tried using the following but it returns "iv":
System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
I know Unity provides Application.systemLanguage
, but that is not in the two letter ISO language code that I need. Is there a reliable way to get the current language of the mobile device, in particular for Android devices?
I found this one, really easy: https://github.com/$$anonymous$$artinSchultz/unity3d/blob/master/LanguageHelper.cs
Cheers!
Answer by GabrielS · Sep 11, 2013 at 03:36 PM
I've just ran into this issue, the "Culture" APIs look completely useless. From what i can tell, we have to manually map the enum values in Application.systemLanguage to the two-letter codes, which of course loses the regional info (i.e. you can't discern between en-US and en-GB, you'll have to pick a default one for "English").
Indeed, that's what I am currently doing to bypass that problem. Thanks for your answer!
Someone posted a LanguageHelper.cs file on GitHub, which does the mapping of the enum to the two letter country code: https://github.com/$$anonymous$$artinSchultz/unity3d/blob/master/LanguageHelper.cs