Initial Language Spanish (Mexico) not detected

More
1 year 6 months ago #2939 by dwebb
Hi,
When I select Espanol (Latinoamerica) on iOS, the device thinks the iso is es-419, which picks Es over Es-US, any way of fixing this?

IPad ios: 11.2.2
I2 v2.8.5 f1

Thanks,
Dave

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago - 1 year 6 months ago #2940 by enghoff
I worked around the issue by integrating assetstore.unity.com/packages/tools/inte...precise-locale-65836 with LocalizationManager_SystemLanguage.cs
    public static partial class LocalizationManager
    {
        static string mCurrentDeviceLanguage;

        public static string GetCurrentDeviceLanguage()
        {
            if (string.IsNullOrEmpty(mCurrentDeviceLanguage))
                DetectDeviceLanguage();

            return mCurrentDeviceLanguage;
        }

        static void DetectDeviceLanguage()
        {
            switch (PreciseLocale.GetLanguageID())
            {
                case "es_MX":
                case "es_US":
                    mCurrentDeviceLanguage = "Spanish (Mexico)";
                    break;

                case "pt_BR":
                    mCurrentDeviceLanguage = "Portuguese (Brazil)";
                    break;

                default:
                    mCurrentDeviceLanguage = Application.systemLanguage.ToString();

                    if (mCurrentDeviceLanguage == "ChineseSimplified") mCurrentDeviceLanguage = "Chinese (Simplified)";
                    if (mCurrentDeviceLanguage == "ChineseTraditional") mCurrentDeviceLanguage = "Chinese (Traditional)";
                    break;
            }
        }
    }
Last edit: 1 year 6 months ago by enghoff. Reason: Formatting
The following user(s) said Thank You: studenman

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #2941 by studenman
This is a useful plugin, I was not aware that Application.systemLanguage didn't return precise regions (like es-MX and en-GB).

I'm currently using "es" to be all Latin-America and Mexico regions and es-ES for European Spanish. Seems like most of the "es" language region variations would be most similar to Mexico rather than to European Spanish.

Based upon your suggestion and the code in I2L v2.8.5f1, I've changed DetectDeviceLanguage() like this. Thoughts?
        static void DetectDeviceLanguage()
        {
            var code = PreciseLocale.GetLanguageID();
            if (!string.IsNullOrEmpty(code))
            {
                code = code.Replace('_', '-');
                mCurrentDeviceLanguage = GoogleLanguages.GetLanguageName(code, true, true);
                if (!string.IsNullOrEmpty(mCurrentDeviceLanguage))
                    return;
            }

            mCurrentDeviceLanguage = Application.systemLanguage.ToString();
            if (mCurrentDeviceLanguage == "ChineseSimplified") mCurrentDeviceLanguage = "Chinese (Simplified)";
            if (mCurrentDeviceLanguage == "ChineseTraditional") mCurrentDeviceLanguage = "Chinese (Traditional)";
        }

Follow Tiny Bubbles Development:
Twitter | Facebook | Web

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #2944 by enghoff
To me that looks as a likely valid general solution :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.338 seconds
Template by JoomlaShine