In xamarin, how to get the current language of the device for Android?

13,915

Solution 1

Here's a cross platform version I use. Obviously you can pull whatever property you need from CurrentUICulture.

return CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

Maybe it will help someone else.

Solution 2

This appears to be what you are looking for: http://androidapi.xamarin.com/?link=T%3aSystem.Globalization.RegionInfo

The RegionInfo class appears to have access for various ways to read that language information and use in your comparisons.

Based on this question, I went to the Xamarin documentation looking for the answer: Get the current language in device

Share:
13,915
user769923
Author by

user769923

Updated on June 05, 2022

Comments

  • user769923
    user769923 about 2 years

    How could I get the current language of the device in Xamarin (for Android)?

    Got the language with context.Resources.Configuration.Locale.Language

    • TronicZomB
      TronicZomB over 11 years
    • user769923
      user769923 over 11 years
      @TronicZomB yes I do not know in Xamarin how to use something like Locale.getDefault().getLanguage()
    • user769923
      user769923 over 11 years
      got the language with context.Resources.Configuration.Locale.Language
  • user769923
    user769923 over 11 years
    Thanks Martin. The RegionInfo can get me some region names. I have got the current language by context.Resources.Configuration.Locale.Language.
  • Wtower
    Wtower over 5 years
    using System.Globalization; Mind that there have been occasional bugs with this.
  • user1034912
    user1034912 almost 3 years
    @Wtower errr What bug?? Seriously this important for my app!