localizely/intl_utils

Inconsistency in languageName causing Traditional Chinese (TW) to fail switching correctly.

Opened this issue · 1 comments

When using intl_utils:generate to generate messages_{language}.dart for Traditional Chinese (TW), the language code in Dart is 'zh_Hant-TW'. However, when the Android system language is Traditional Chinese (TW), the language code passed to the initializeMessages method in messages_all.dart is 'zh_Hant_TW', causing an issue with language switching. This problem is likely due to a difference in language codes between Dart and the Android system.

The red box is the languageName of the system
The yellow box is the languageName created by intl_utils:generate

image

lzoran commented

Thank you for pointing this out!

It seems this might be related to the issue discussed here. The root of the problem appears to be with Intl.canonicalizedLocale from the intl package, which isn't handling locale strings with script code appropriately.

Temporary Fix: You could try setting the locale metadata to "@@locale": "zh_Hant_TW" in your .arb file for Traditional Chinese (Taiwan). This should temporarily fix this problem until we find a better solution.