firebase / FirebaseUI-Flutter

Apache License 2.0
99 stars 86 forks source link

🐛 [firebase_ui_localizations] Traditional Chinese is not loading #33

Closed outdoorapps closed 10 months ago

outdoorapps commented 1 year ago

Traditional Chinese will not be loaded in Firebase UI Auth using the standard locales as described here. (Simplified Chinese can be properly loaded).

This issue is caused by the non-standard key zh_tw In /lib/src/all_languages.dart (see below). It should have been zh_TW.

final localizations = <String, FirebaseUILocalizationLabels>{
  ...
  'zh': const ZhLocalizations(),
  'zh_tw': const ZhTWLocalizations(),
  ...
};

I suggest the following fix to match the standard given by Flutter in the previous URL.

In /lib/src/all_languages.dart:

final localizations = <String, FirebaseUILocalizationLabels>{
  ...
  'zh': const ZhLocalizations(), // Simplified Chinese
  'zh_Hans': const ZhLocalizations(), // Simplified Chinese
  'zh_Hant': const ZhTWLocalizations(), // Traditional Chinese
  'zh_Hans_CN': const ZhLocalizations(), // Simplified Chinese
  'zh_Hant_TW': const ZhTWLocalizations(), // Traditional Chinese
  'zh_Hant_HK': const ZhTWLocalizations(), // Traditional Chinese
  ...
};

In /lib/src/l10n.dart:

@override
  Future<FirebaseUILocalizations> load(Locale locale) {
    late FirebaseUILocalizationLabels labels;

    final key = locale.languageCode;
    // Change this line to include script code
    final scriptCode = locale.scriptCode;
    final countryCode = locale.countryCode;
    var fullKey = key;

    scriptCode != null ? fullKey += '_$scriptCode' : null;
    countryCode != null ? fullKey += '_$countryCode' : null;
    ...
  }
darshankawar commented 1 year ago

/cc @lesnitsky

david675566 commented 1 year ago

+1 on this issue, it's really bugging me a lot that i had to edit out of scope files just to make Traditional Chinese works