From ed539c31b85821665a5f48c43c635610ad68a36f Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Thu, 4 May 2023 16:50:14 -0700 Subject: [PATCH] Remap zh-TW to zh-Hant to match Traditional Chinese in other regions --- _locales/{zh-TW => zh-Hant}/messages.json | 0 build/available-locales.json | 4 ++-- ts/scripts/get-strings.ts | 7 +++++++ ts/test-node/app/locale_test.ts | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) rename _locales/{zh-TW => zh-Hant}/messages.json (100%) diff --git a/_locales/zh-TW/messages.json b/_locales/zh-Hant/messages.json similarity index 100% rename from _locales/zh-TW/messages.json rename to _locales/zh-Hant/messages.json diff --git a/build/available-locales.json b/build/available-locales.json index 8f0f13c0b..0eaea2a78 100644 --- a/build/available-locales.json +++ b/build/available-locales.json @@ -66,6 +66,6 @@ "vi", "yue", "zh-CN", - "zh-HK", - "zh-TW" + "zh-Hant", + "zh-HK" ] diff --git a/ts/scripts/get-strings.ts b/ts/scripts/get-strings.ts index b0529f5dd..d3cdd8b79 100644 --- a/ts/scripts/get-strings.ts +++ b/ts/scripts/get-strings.ts @@ -44,6 +44,13 @@ function rename(from: string, to: string) { // "zh-YU" actually implies "Chinese as spoken in Yugoslavia (canonicalized to Serbia)" rename('zh-YU', 'yue'); +// For most of the Chinese-speaking world, where we don't have a region specific +// locale available (e.g. zh-HK), zh-TW is a suitable choice for "Traditional Chinese". +// +// However, Intl.LocaleMatcher won't match "zh-Hant-XX" to "zh-TW", +// we need to rename it to "zh-Hant" explicitly to make it work. +rename('zh-TW', 'zh-Hant'); + console.log('Formatting newly-downloaded strings!'); console.log(); execSync('yarn format', { diff --git a/ts/test-node/app/locale_test.ts b/ts/test-node/app/locale_test.ts index b5c4b287e..f6881b68a 100644 --- a/ts/test-node/app/locale_test.ts +++ b/ts/test-node/app/locale_test.ts @@ -35,7 +35,9 @@ describe('locale', async () => { await testCase(['an', 'fr-FR'], 'fr'); // If we ever add support for Aragonese, this test will fail. // Specific cases we want to ensure work as expected - await testCase(['zh-Hant-TW'], 'zh-TW'); + await testCase(['zh-TW'], 'zh-Hant'); + await testCase(['zh-Hant-TW'], 'zh-Hant'); + await testCase(['zh-Hant-CA'], 'zh-Hant'); await testCase(['zh-Hant-HK'], 'zh-HK'); await testCase(['zh'], 'zh-CN'); await testCase(['yue'], 'yue');