Beispiel #1
0
        public List <string> GetSupportedLanguages()
        {
            var activity                    = Locator.Current.GetService <Activity>();
            LocaleListCompat locales        = ConfigurationCompat.GetLocales(activity.Resources.Configuration);
            List <String>    localLanguages = new List <String>();

            for (int i = 0; i < locales.Size(); i++)
            {
                localLanguages.Add(locales.Get(i).Language);
            }
            return(localLanguages);
        }
Beispiel #2
0
            /// <summary>
            /// Sets the language to the device language (en-US) or the language prefix (en) or to nothing if not found
            /// </summary>
            public static void SetUserLanguage()
            {
                LocaleListCompat lst = ConfigurationCompat.GetLocales(Resources.System.Configuration);

                if (Languages.ContainsKey(lst.ToLanguageTags()))
                {
                    SetLanguage(Languages[lst.ToLanguageTags()]);
                    Log.Debug("LoCa", "Set language to " + lst.ToLanguageTags());
                    return;
                }
                if (Languages.ContainsKey(lst.ToLanguageTags().Split('-')[0]))
                {
                    SetLanguage(Languages[lst.ToLanguageTags().Split('-')[0]]);
                    Log.Debug("LoCa", "Set language to " + lst.ToLanguageTags().Split('-')[0]);
                    return;
                }
            }