From 3822ee9f00a7d5cff3bdfb410cb4fa2d1b99fd0d Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Fri, 13 Nov 2026 20:07:44 +0400 Subject: [PATCH] =?UTF-8?q?i18n:=20keep=20=E4=B8=A6=20before=20=E9=81=93?= =?UTF-8?q?=E8=B7=AF,=20=E9=81=93=E6=AD=89=20and=20=E9=81=93=E7=90=86=20in?= =?UTF-8?q?=20zh-Hant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 並道 → 併道 correction replaced the substring anywhere, so a zh-CN string where 并 means "and" and 道 starts the next word would turn into 併道路 or 併道歉. It now skips 道路, 道歉 and 道理. The three current entries (lane merging) convert as before; zh-Hant.json does not change. --- docs/translations/zh-Hant.md | 2 +- scripts/i18n.mjs | 3 ++- src/i18n/catalog.test.mjs | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/translations/zh-Hant.md b/docs/translations/zh-Hant.md index 9b58ba347..bedef3d8b 100644 --- a/docs/translations/zh-Hant.md +++ b/docs/translations/zh-Hant.md @@ -10,7 +10,7 @@ npm run i18n -- --zh-hant # rewrite zh-Hant.json from zh-CN.json `npm test` fails when `zh-Hant.json` differs from the conversion of `zh-CN.json`, naming the entry, and `npm run i18n -- --missing zh-Hant` points to this command instead of printing a template. -The command converts with OpenCC `s2tw` ([opencc-js](https://github.com/nk2028/opencc-js), `cn` → `tw`), which changes characters only. Never `s2twp`: it also swaps in Taiwan vocabulary (影片, 伺服器, 載入, 圖示), which this catalog does not use. After the conversion it fixes the characters OpenCC picks wrongly here: 年曆史 → 年歷史, 下遊 → 下游, 並道 → 併道, 發佈 → 發布, 公佈 → 公布, 控制檯 → 控制台, and 周 → 週 where it means a week (1 週/秒). The list is `ZH_HANT_CORRECTIONS` in `scripts/i18n.mjs`; when the conversion picks another wrong character, add the pair there and run the command. +The command converts with OpenCC `s2tw` ([opencc-js](https://github.com/nk2028/opencc-js), `cn` → `tw`), which changes characters only. Never `s2twp`: it also swaps in Taiwan vocabulary (影片, 伺服器, 載入, 圖示), which this catalog does not use. After the conversion it fixes the characters OpenCC picks wrongly here: 年曆史 → 年歷史, 下遊 → 下游, 並道 → 併道 (not in 並道路, 並道歉, 並道理), 發佈 → 發布, 公佈 → 公布, 控制檯 → 控制台, and 周 → 週 where it means a week (1 週/秒). The list is `ZH_HANT_CORRECTIONS` in `scripts/i18n.mjs`; when the conversion picks another wrong character, add the pair there and run the command. An entry `zh-CN` keeps in English on purpose needs the same line under `zh-Hant` in `src/i18n/same-as-english.json`. diff --git a/scripts/i18n.mjs b/scripts/i18n.mjs index 01321605a..b125a7a53 100644 --- a/scripts/i18n.mjs +++ b/scripts/i18n.mjs @@ -634,7 +634,8 @@ const ZH_HANT_COMMAND = 'npm run i18n -- --zh-hant'; const ZH_HANT_CORRECTIONS = [ ['年曆史', '年歷史'], ['下遊', '下游'], - ['並道', '併道'], + // 併道 is merging lanes; 並 stays when 道 starts 道路, 道歉 or 道理. + [/並道(?![路歉理])/g, '併道'], ['發佈', '發布'], ['公佈', '公布'], ['控制檯', '控制台'], diff --git a/src/i18n/catalog.test.mjs b/src/i18n/catalog.test.mjs index 9b6bb5d9b..010e533cd 100644 --- a/src/i18n/catalog.test.mjs +++ b/src/i18n/catalog.test.mjs @@ -54,6 +54,12 @@ test('toZhHant converts characters, not vocabulary, and fixes what s2tw picks wr assert.equal(toZhHant('50 年历史'), '50 年歷史'); assert.equal(toZhHant('发布于 {date}'), '發布於 {date}'); assert.equal(toZhHant('1 周/秒'), '1 週/秒'); + assert.equal( + toZhHant('{direction}并道,进入 {road}'), + '{direction}併道,進入 {road}', + ); + assert.equal(toZhHant('事故并道路封闭'), '事故並道路封閉'); + assert.equal(toZhHant('已关闭并道歉'), '已關閉並道歉'); }); test('checkZhHant names each entry that is not the conversion of zh-CN', () => {