Skip to content

Commit d6a4959

Browse files
PIG208gnprice
authored andcommitted
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 1bb8206 commit d6a4959

File tree

5 files changed

+822
-0
lines changed

5 files changed

+822
-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.
@@ -1432,13 +1444,22 @@ class _ZulipLocalizationsDelegate
14321444
'ru',
14331445
'sk',
14341446
'uk',
1447+
'zh',
14351448
].contains(locale.languageCode);
14361449

14371450
@override
14381451
bool shouldReload(_ZulipLocalizationsDelegate old) => false;
14391452
}
14401453

14411454
ZulipLocalizations lookupZulipLocalizations(Locale locale) {
1455+
// Lookup logic when language+script+country codes are specified.
1456+
switch (locale.toString()) {
1457+
case 'zh_Hans_CN':
1458+
return ZulipLocalizationsZhHansCn();
1459+
case 'zh_Hant_TW':
1460+
return ZulipLocalizationsZhHantTw();
1461+
}
1462+
14421463
// Lookup logic when language+country codes are specified.
14431464
switch (locale.languageCode) {
14441465
case 'en':
@@ -1471,6 +1492,8 @@ ZulipLocalizations lookupZulipLocalizations(Locale locale) {
14711492
return ZulipLocalizationsSk();
14721493
case 'uk':
14731494
return ZulipLocalizationsUk();
1495+
case 'zh':
1496+
return ZulipLocalizationsZh();
14741497
}
14751498

14761499
throw FlutterError(

0 commit comments

Comments
 (0)