3
votes

I need to know what language is used on a iOS/Android device because I build a MonoGame application in Xamarin Studio that supports three different languages. If the current language of the device is english, than the app will show texts in english, but if the current language of the device is french, than the texts will get displayed in french instead of english. If the current language of the device is not supported in my application(for example chinese), than the default language for the texts will be english.

How can I get the current device language on iOS/Android in Xamarin Studio?

3

3 Answers

3
votes

To get the language programmatically, on Android you can use:

Locale.Default.GetDisplayLanguage(Locale.Default)

On iOS :

var userLang = NSLocale.CurrentLocale.LocaleIdentifier;
2
votes

You could use CultureInfo:

CultureInfo.CurrentCulture.TwoLetterISOLanguageName

Plus is cross-platform.

0
votes

1) Open settings, on the home screen, tap settings 2) Tap general, on the next screen, tap general 3) Select language and region. If you're using iOS 8 or later, scroll down and tap Language & Region 4) Tap device language, on the next screen, tap "[device] Language"

That should fix your issue. However, if this does not resolve your issue, then see here