zh-'h'ans / zh-'h'ant locale code mismatch with locale codes within localization package ('H')

Hi,

I’m localizing my game in Chinese, traditional and simplified. In Unity (localization package 0.10-preview), I generated the following locales: zh-Hant and zh-Hans.

When trying to test it on a test device, I found a problem where Chinese what not found in the locales, even though I switched my phone’s language. My phone is not a “Chinese” phone so I can only change the language and not the CultureInfo.

Tracing the problem, I found out that my phone returns “Invariant Culture info” which makes SystemLocaleSelector.cs branch out to using the system language to find the locale.

Problem is, in SystemLanguageConverter.cs:

case SystemLanguage.ChineseSimplified:  return "zh-hans";
                case SystemLanguage.ChineseTraditional: return "zh-hant";

we get language codes with lowercase ‘h’ whereas the codes in the available locales are using ‘H’. Although the created LocaleIdentifier is technically OK as Chinese, the matching fails in LocaleProvider.cs (line 55):

public Locale GetLocale(LocaleIdentifier id)
        {
            foreach (var locale in Locales)
            {
                if (locale.Identifier.Equals(id))
                    return locale;
            }
            return null;
        }

If I hardcode a cultureInfo to (zh-HK), I can see that the code fails to find a direct match but because the culture info was properly created, the localization feature properly checks for the parent culture and properly finds ‘zh-Hant’. (with capital ‘H’)

Not sure if the proper solution is to change to a capital ‘H’ in SystemLanguageConverter. Any thoughts?

Thanks!

Ah this looks like a bug. Could you please file a bug report?

Hi!

I submitted a bug report (Case 1318190): https://fogbugz.unity3d.com/default.asp?1318190_22047un9e9dg9f0c

Not sure if I was supposed to specifically tag the localization package somehow. I used the bug reporting tool in Unity.

While creating the sample project, I found out that zh-Hant/Hans was duplicated between CultureInfo and SystemLanguage but with different capitalization. I find that using the ‘hans/hant’ locales in lowercase would be the best approach for now as the SystemLanguage fallback with lowercase codes would work to cover most cases whereas using Hant/Hans would work only for proper cultureInfo on phones but fail to support the CultureInfo.Invariant cases.

6887756--805226--ChineseLocales_CultureInfo.png 6887756--805229--ChineseLocales_SystemLanguage.png 6887756--805232--ChineseLocalesNotFound_DebugLogs.png