Ejemplo n.º 1
0
        public static string GetBestGuessForLocale()
        {
            string result = "enUS";
            bool   flag   = false;
            string text   = MobileDeviceLocale.GetLanguageCode();

            try
            {
                flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(text, out result);
            }
            catch (Exception)
            {
            }
            if (!flag)
            {
                text = text.Substring(0, 2);
                try
                {
                    flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(text, out result);
                }
                catch (Exception)
                {
                }
            }
            if (!flag || text == "es")
            {
                int    num         = 1;
                string countryCode = MobileDeviceLocale.GetCountryCode();
                try
                {
                    MobileDeviceLocale.s_countryCodeToRegionId.TryGetValue(countryCode, out num);
                }
                catch (Exception)
                {
                }
                if (text != null)
                {
                    if (text == "es")
                    {
                        if (num == 1)
                        {
                            result = "esMX";
                        }
                        else
                        {
                            result = "esES";
                        }
                        return(result);
                    }
                    if (text == "zh")
                    {
                        if (countryCode == "CN")
                        {
                            result = "zhCN";
                        }
                        else
                        {
                            result = "zhTW";
                        }
                        return(result);
                    }
                }
                result = "enUS";
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static string GetBestGuessForLocale()
        {
            string str = SecurePlayerPrefs.GetString(MobileDeviceLocale.LocaleKey, Main.uniqueIdentifier);

            if (!string.IsNullOrEmpty(str))
            {
                return(str);
            }
            string str1         = "enUS";
            bool   flag         = false;
            string languageCode = MobileDeviceLocale.GetLanguageCode();

            try
            {
                flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(languageCode, out str1);
            }
            catch (Exception exception)
            {
            }
            if (!flag)
            {
                languageCode = languageCode.Substring(0, 2);
                try
                {
                    flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(languageCode, out str1);
                }
                catch (Exception exception1)
                {
                }
            }
            if (!flag || languageCode == "es")
            {
                int    num         = 1;
                string countryCode = MobileDeviceLocale.GetCountryCode();
                try
                {
                    MobileDeviceLocale.s_countryCodeToRegionId.TryGetValue(countryCode, out num);
                }
                catch (Exception exception2)
                {
                }
                if (languageCode != null)
                {
                    if (languageCode == "es")
                    {
                        str1 = (num != 1 ? "esES" : "esMX");
                        return(str1);
                    }
                    else
                    {
                        if (languageCode != "zh")
                        {
                            goto Label2;
                        }
                        str1 = (countryCode != "CN" ? "zhTW" : "zhCN");
                        return(str1);
                    }
                }
Label2:
                str1 = "enUS";
            }
            return(str1);
        }
Ejemplo n.º 3
0
 public static bool IsChineseDevice()
 {
     return(MobileDeviceLocale.GetCountryCode().Equals("CN", StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 4
0
        public static string GetBestGuessForLocale()
        {
            if (!string.IsNullOrEmpty(MobileDeviceLocale.s_bestGuessLocale))
            {
                return(MobileDeviceLocale.s_bestGuessLocale);
            }
            string @string = SecurePlayerPrefs.GetString(MobileDeviceLocale.LocaleKey, Main.uniqueIdentifier);

            if (!string.IsNullOrEmpty(@string))
            {
                MobileDeviceLocale.s_bestGuessLocale = @string;
                return(MobileDeviceLocale.s_bestGuessLocale);
            }
            string text  = "enUS";
            bool   flag  = false;
            string text2 = MobileDeviceLocale.GetLanguageCode();

            try
            {
                flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(text2, out text);
            }
            catch (Exception)
            {
            }
            if (!flag)
            {
                text2 = text2.Substring(0, 2);
                try
                {
                    flag = MobileDeviceLocale.s_languageCodeToLocale.TryGetValue(text2, out text);
                }
                catch (Exception)
                {
                }
            }
            if (!flag || text2 == "es")
            {
                int    num         = 1;
                string countryCode = MobileDeviceLocale.GetCountryCode();
                try
                {
                    MobileDeviceLocale.s_countryCodeToRegionId.TryGetValue(countryCode, out num);
                }
                catch (Exception)
                {
                }
                if (text2 != null)
                {
                    if (text2 == "es")
                    {
                        if (num == 1)
                        {
                            text = "esMX";
                        }
                        else
                        {
                            text = "esES";
                        }
                        goto IL_140;
                    }
                    if (text2 == "zh")
                    {
                        if (countryCode == "CN")
                        {
                            text = "zhCN";
                        }
                        else
                        {
                            text = "zhTW";
                        }
                        goto IL_140;
                    }
                }
                text = "enUS";
            }
IL_140:
            MobileDeviceLocale.s_bestGuessLocale = text;
            return(MobileDeviceLocale.s_bestGuessLocale);
        }