localizely / intl_utils

Dart package that creates a binding between your translations from .arb files and your Flutter app
BSD 3-Clause "New" or "Revised" License
135 stars 81 forks source link

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

Open EanLee opened 1 year ago

EanLee commented 1 year ago

When using intlutils: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 1 year ago

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.