public override Locale GetStartupLocale(LocalesProvider availableLocales)
        {
            if (string.IsNullOrEmpty(m_CommandLineArgument))
            {
                return(null);
            }

            foreach (var arg in Environment.GetCommandLineArgs())
            {
                if (arg.StartsWith(m_CommandLineArgument, StringComparison.OrdinalIgnoreCase))
                {
                    var argValue    = arg.Substring(m_CommandLineArgument.Length);
                    var foundLocale = availableLocales.GetLocale(argValue);

                    if (foundLocale != null)
                    {
                        Debug.LogFormat("Found a matching locale({0}) for command line argument: `{1}`.", argValue, foundLocale);
                    }
                    else
                    {
                        Debug.LogWarningFormat("Could not find a matching locale for command line argument: `{0}`", argValue);
                    }

                    return(foundLocale);
                }
            }
            return(null);
        }
Esempio n. 2
0
        public override Locale GetStartupLocale(LocalesProvider availableLocales)
        {
            Locale locale = null;

            if (Application.systemLanguage != SystemLanguage.Unknown)
            {
                locale = availableLocales.GetLocale(Application.systemLanguage);
            }

            if (locale == null)
            {
                var cultureInfo = CultureInfo.CurrentUICulture;
                locale = availableLocales.GetLocale(cultureInfo);
                if (locale == null)
                {
                    // Attempt to use CultureInfo fallbacks to find the closest locale
                    while (!Equals(cultureInfo, CultureInfo.InvariantCulture) && locale == null)
                    {
                        locale      = availableLocales.GetLocale(cultureInfo);
                        cultureInfo = cultureInfo.Parent;
                    }

                    if (locale != null)
                    {
                        Debug.Log(string.Format("Locale '{0}' is not supported, however the parent locale '{1}' is.", CultureInfo.CurrentUICulture, locale.Identifier.CultureInfo));
                    }
                }
            }
            return(locale);
        }
Esempio n. 3
0
        public override Locale GetStartupLocale(LocalesProvider availableLocales)
        {
            if (string.IsNullOrEmpty(Player_Pref_Key))
            {
                return(null);
            }

            var savedKey = "";

            if (UseCustomID && string.IsNullOrEmpty(CustomID))
            {
                savedKey = PlayerPrefs.GetString(Player_Pref_Key + "_" + CustomID, "");
            }

            if (string.IsNullOrEmpty(savedKey))
            {
                savedKey = PlayerPrefs.GetString(Player_Pref_Key, "");
            }

            if (string.IsNullOrEmpty(savedKey))
            {
                return(null);
            }

            var locale = availableLocales.GetLocale(savedKey);

            Debug.Log($"Detect Lang by SavedLocaleSelector :{savedKey} matched: {locale}");
            return(locale);
        }
 public override Locale GetStartupLocale(LocalesProvider availableLocales)
 {
     foreach (var startupLocaleSelector in m_StartupSelectors)
     {
         if (startupLocaleSelector != null)
         {
             var locale = startupLocaleSelector.GetStartupLocale(availableLocales);
             if (locale != null)
             {
                 return(locale);
             }
         }
     }
     return(null);
 }
Esempio n. 5
0
        public override Locale GetStartupLocale(LocalesProvider availableLocales)
        {
            Locale locale = null;

            string currentDeviceLanguage = NativeLocale.GetLanguage(true, true);

            if (!string.IsNullOrEmpty(currentDeviceLanguage))
            {
                locale = availableLocales.Locales.GetLocale(currentDeviceLanguage, AllowSimillarCoutryCode);
            }
            Debug.Log($"Detect Lang By Device:{currentDeviceLanguage} matched locale {locale}");

            if (locale != null)
            {
                return(locale);
            }

            if (Application.systemLanguage != SystemLanguage.Unknown)
            {
                locale = availableLocales.GetLocale(Application.systemLanguage);
            }

            if (locale == null)
            {
                var cultureInfo = CultureInfo.CurrentUICulture;
                locale = availableLocales.GetLocale(cultureInfo);
                if (locale == null)
                {
                    // Attempt to use CultureInfo fallbacks to find the closest locale
                    while (!Equals(cultureInfo, CultureInfo.InvariantCulture) && locale == null)
                    {
                        locale      = availableLocales.GetLocale(cultureInfo);
                        cultureInfo = cultureInfo.Parent;
                    }

                    if (locale != null)
                    {
                        Debug.Log(
                            $"Locale '{CultureInfo.CurrentUICulture}' is not supported, however the parent locale '{locale.Identifier.CultureInfo}' is.");
                    }
                }
            }
            return(locale);
        }
 public override Locale GetStartupLocale(LocalesProvider availableLocales)
 {
     return(availableLocales.GetLocale(LocaleId));
 }
Esempio n. 7
0
 /// <summary>
 /// Determine which <see cref="Locale"/> should be used.
 /// </summary>
 /// <param name="availableLocales">The available locales to select from.</param>
 /// <returns>The selected locale or null.</returns>
 public abstract Locale GetStartupLocale(LocalesProvider availableLocales);