Skip to content

Commit 20862cf

Browse files
committed
l10n: Add zh, zh-Hans-CN, and zh-Hant-TW
Normally, instead of doing it manually, we would add new languages from Weblate's UI. In this case, the ones added in this commit are not offered there. So we will commit this to GitHub first, and let Weblate pull the changes from there. The language identifier zh is left empty, and is set to be ignored on Weblate for translations. Translator will be expected translate strings for zh-Hans-CN and zh-Hant-TW instead. We can add more locales with the zh language code if users request them. See CZO discussion on how we picked these language identifiers: https://chat.zulip.org/#narrow/channel/58-translation/topic/zh_*.20in.20Weblate/near/2177452
1 parent 63f712a commit 20862cf

File tree

5 files changed

+816
-0
lines changed

5 files changed

+816
-0
lines changed

assets/l10n/app_zh.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

assets/l10n/app_zh_Hans_CN.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"settingsPageTitle": "设置"
3+
}

assets/l10n/app_zh_Hant_TW.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"settingsPageTitle": "設定"
3+
}

lib/generated/l10n/zulip_localizations.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'zulip_localizations_pl.dart';
1414
import 'zulip_localizations_ru.dart';
1515
import 'zulip_localizations_sk.dart';
1616
import 'zulip_localizations_uk.dart';
17+
import 'zulip_localizations_zh.dart';
1718

1819
// ignore_for_file: type=lint
1920

@@ -111,6 +112,17 @@ abstract class ZulipLocalizations {
111112
Locale('ru'),
112113
Locale('sk'),
113114
Locale('uk'),
115+
Locale('zh'),
116+
Locale.fromSubtags(
117+
languageCode: 'zh',
118+
countryCode: 'CN',
119+
scriptCode: 'Hans',
120+
),
121+
Locale.fromSubtags(
122+
languageCode: 'zh',
123+
countryCode: 'TW',
124+
scriptCode: 'Hant',
125+
),
114126
];
115127

116128
/// Title for About Zulip page.
@@ -1420,13 +1432,22 @@ class _ZulipLocalizationsDelegate
14201432
'ru',
14211433
'sk',
14221434
'uk',
1435+
'zh',
14231436
].contains(locale.languageCode);
14241437

14251438
@override
14261439
bool shouldReload(_ZulipLocalizationsDelegate old) => false;
14271440
}
14281441

14291442
ZulipLocalizations lookupZulipLocalizations(Locale locale) {
1443+
// Lookup logic when language+script+country codes are specified.
1444+
switch (locale.toString()) {
1445+
case 'zh_Hans_CN':
1446+
return ZulipLocalizationsZhHansCn();
1447+
case 'zh_Hant_TW':
1448+
return ZulipLocalizationsZhHantTw();
1449+
}
1450+
14301451
// Lookup logic when language+country codes are specified.
14311452
switch (locale.languageCode) {
14321453
case 'en':
@@ -1459,6 +1480,8 @@ ZulipLocalizations lookupZulipLocalizations(Locale locale) {
14591480
return ZulipLocalizationsSk();
14601481
case 'uk':
14611482
return ZulipLocalizationsUk();
1483+
case 'zh':
1484+
return ZulipLocalizationsZh();
14621485
}
14631486

14641487
throw FlutterError(

0 commit comments

Comments
 (0)