From 9410e5bb2a87d28cd1a43bf42d769e1f2b3dec45 Mon Sep 17 00:00:00 2001 From: HuanLinOTO Date: Sun, 23 Aug 2026 20:58:33 +0800 Subject: [PATCH] fix(i18n): add worktree translation to all 19 third-language dicts (#285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #285 added the zh/en 'worktree' key but the 19 third-language dicts (de/fr/pt/ko/ar/hi/id/tr/vi/th/ru/it/nl/sv/pl/zhHK/zhTW/zhMO) were missing it — only ja was patched in the prior commit. The dicts are typed Record via an unchecked 'as' cast, so tsc did not catch the gap. This commit: - adds the worktree translation to all 19 dicts - strengthens tests/locales.spec.ts to assert key-set equality for EVERY shipped dictionary (not just zh/en/ja), preventing future regressions --- src/client/locales-ar.ts | 1 + src/client/locales-de.ts | 1 + src/client/locales-fr.ts | 1 + src/client/locales-hi.ts | 1 + src/client/locales-id.ts | 1 + src/client/locales-it.ts | 1 + src/client/locales-ko.ts | 1 + src/client/locales-nl.ts | 1 + src/client/locales-pl.ts | 1 + src/client/locales-pt.ts | 1 + src/client/locales-ru.ts | 1 + src/client/locales-sv.ts | 1 + src/client/locales-th.ts | 1 + src/client/locales-tr.ts | 1 + src/client/locales-vi.ts | 1 + src/client/locales-zh-HK.ts | 1 + src/client/locales-zh-MO.ts | 1 + src/client/locales-zh-TW.ts | 1 + tests/locales.spec.ts | 14 +++++++++++++- 19 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/client/locales-ar.ts b/src/client/locales-ar.ts index 55901f3..8ce5692 100644 --- a/src/client/locales-ar.ts +++ b/src/client/locales-ar.ts @@ -107,6 +107,7 @@ export const ar: Record = { commit: 'تثبيت', commitError: 'فشل التثبيت', branch: 'الفرع', + worktree: 'شجرة العمل', checkoutError: 'فشل تبديل الفرع', history: 'السجل', changes: 'التغييرات', diff --git a/src/client/locales-de.ts b/src/client/locales-de.ts index d42b5fe..b555d3b 100644 --- a/src/client/locales-de.ts +++ b/src/client/locales-de.ts @@ -92,6 +92,7 @@ export const de: Record = { commit: 'Committen', commitError: 'Commit fehlgeschlagen', branch: 'Branch', + worktree: 'Worktree', checkoutError: 'Branchenwechsel fehlgeschlagen', history: 'Verlauf', changes: 'Änderungen', diff --git a/src/client/locales-fr.ts b/src/client/locales-fr.ts index 3bc2de8..79b9f5e 100644 --- a/src/client/locales-fr.ts +++ b/src/client/locales-fr.ts @@ -99,6 +99,7 @@ export const fr: Record = { commit: 'Valider', commitError: 'Échec du commit', branch: 'Branche', + worktree: 'Arborescence de travail', checkoutError: 'Échec du changement de branche', history: 'Historique', changes: 'Modifications', diff --git a/src/client/locales-hi.ts b/src/client/locales-hi.ts index c65772a..7160335 100644 --- a/src/client/locales-hi.ts +++ b/src/client/locales-hi.ts @@ -106,6 +106,7 @@ export const hi: Record = { commit: 'कमिट', commitError: 'कमिट विफल', branch: 'ब्रांच', + worktree: 'वर्कट्री', checkoutError: 'ब्रांच स्विच विफल', history: 'इतिहास', changes: 'बदलाव', diff --git a/src/client/locales-id.ts b/src/client/locales-id.ts index 74db07f..5a01859 100644 --- a/src/client/locales-id.ts +++ b/src/client/locales-id.ts @@ -104,6 +104,7 @@ export const id: Record = { commit: 'Commit', commitError: 'Commit gagal', branch: 'Branch', + worktree: 'Worktree', checkoutError: 'Beralih branch gagal', history: 'Riwayat', changes: 'Perubahan', diff --git a/src/client/locales-it.ts b/src/client/locales-it.ts index fd93783..89a1d65 100644 --- a/src/client/locales-it.ts +++ b/src/client/locales-it.ts @@ -97,6 +97,7 @@ export const it: Record = { commit: 'Commit', commitError: 'Commit non riuscito', branch: 'Ramo', + worktree: 'Albero di lavoro', checkoutError: 'Cambio di ramo non riuscito', history: 'Cronologia', changes: 'Modifiche', diff --git a/src/client/locales-ko.ts b/src/client/locales-ko.ts index 7e3bbd5..97696ea 100644 --- a/src/client/locales-ko.ts +++ b/src/client/locales-ko.ts @@ -98,6 +98,7 @@ export const ko: Record = { commit: '커밋', commitError: '커밋 실패', branch: '브랜치', + worktree: '워크트리', checkoutError: '브랜치 전환 실패', history: '기록', changes: '변경 사항', diff --git a/src/client/locales-nl.ts b/src/client/locales-nl.ts index 252d3dc..c6144bc 100644 --- a/src/client/locales-nl.ts +++ b/src/client/locales-nl.ts @@ -104,6 +104,7 @@ export const nl: Record = { commit: 'Commit', commitError: 'Commit mislukt', branch: 'Branch', + worktree: 'Worktree', checkoutError: 'Wisselen van branch mislukt', history: 'Geschiedenis', changes: 'Wijzigingen', diff --git a/src/client/locales-pl.ts b/src/client/locales-pl.ts index e4adacd..3a38582 100644 --- a/src/client/locales-pl.ts +++ b/src/client/locales-pl.ts @@ -108,6 +108,7 @@ export const pl: Record = { commit: 'Commit', commitError: 'Commit nie powiódł się', branch: 'Gałąź', + worktree: 'Drzewo robocze', checkoutError: 'Przełączenie gałęzi nie powiodło się', history: 'Historia', changes: 'Zmiany', diff --git a/src/client/locales-pt.ts b/src/client/locales-pt.ts index 9c3b209..952bef7 100644 --- a/src/client/locales-pt.ts +++ b/src/client/locales-pt.ts @@ -89,6 +89,7 @@ export const pt: Record = { commit: 'Commit', commitError: 'Falha no commit', branch: 'Branch', + worktree: 'Worktree', checkoutError: 'Falha ao alternar de branch', history: 'Histórico', changes: 'Alterações', diff --git a/src/client/locales-ru.ts b/src/client/locales-ru.ts index f7fa9f1..c2f4afe 100644 --- a/src/client/locales-ru.ts +++ b/src/client/locales-ru.ts @@ -102,6 +102,7 @@ export const ru: Record = { commit: 'Закоммитить', commitError: 'Сбой коммита', branch: 'Ветка', + worktree: 'Рабочее дерево', checkoutError: 'Сбой переключения ветки', history: 'История', changes: 'Изменения', diff --git a/src/client/locales-sv.ts b/src/client/locales-sv.ts index fd28a42..2a50470 100644 --- a/src/client/locales-sv.ts +++ b/src/client/locales-sv.ts @@ -89,6 +89,7 @@ export const sv: Record = { commit: 'Commit', commitError: 'Commit misslyckades', branch: 'Gren', + worktree: 'Arbetsträd', checkoutError: 'Grenbyte misslyckades', history: 'Historik', changes: 'Ändringar', diff --git a/src/client/locales-th.ts b/src/client/locales-th.ts index ce0f6f4..c09bd70 100644 --- a/src/client/locales-th.ts +++ b/src/client/locales-th.ts @@ -106,6 +106,7 @@ export const th: Record = { commit: 'Commit', commitError: 'Commit ล้มเหลว', branch: 'Branch', + worktree: 'เวิร์กทรี', checkoutError: 'สลับ branch ล้มเหลว', history: 'ประวัติ', changes: 'การเปลี่ยนแปลง', diff --git a/src/client/locales-tr.ts b/src/client/locales-tr.ts index bc38c72..90e4831 100644 --- a/src/client/locales-tr.ts +++ b/src/client/locales-tr.ts @@ -106,6 +106,7 @@ export const tr: Record = { commit: 'İşle', commitError: 'İşleme başarısız', branch: 'Dal', + worktree: 'Çalışma ağacı', checkoutError: 'Dal değiştirme başarısız', history: 'Geçmiş', changes: 'Değişiklikler', diff --git a/src/client/locales-vi.ts b/src/client/locales-vi.ts index 5bdfbee..5b62f26 100644 --- a/src/client/locales-vi.ts +++ b/src/client/locales-vi.ts @@ -106,6 +106,7 @@ export const vi: Record = { commit: 'Commit', commitError: 'Commit thất bại', branch: 'Branch', + worktree: 'Worktree', checkoutError: 'Chuyển branch thất bại', history: 'Lịch sử', changes: 'Thay đổi', diff --git a/src/client/locales-zh-HK.ts b/src/client/locales-zh-HK.ts index 2dabfbb..ade8f93 100644 --- a/src/client/locales-zh-HK.ts +++ b/src/client/locales-zh-HK.ts @@ -121,6 +121,7 @@ export const zhHK: Record = { commit: '提交', commitError: '提交失敗', branch: '分支', + worktree: '工作樹', checkoutError: '切換分支失敗', history: '歷史', changes: '變更', diff --git a/src/client/locales-zh-MO.ts b/src/client/locales-zh-MO.ts index f108901..4cd7311 100644 --- a/src/client/locales-zh-MO.ts +++ b/src/client/locales-zh-MO.ts @@ -121,6 +121,7 @@ export const zhMO: Record = { commit: '提交', commitError: '提交失敗', branch: '分支', + worktree: '工作樹', checkoutError: '切換分支失敗', history: '歷史', changes: '變更', diff --git a/src/client/locales-zh-TW.ts b/src/client/locales-zh-TW.ts index e1f8153..3779a13 100644 --- a/src/client/locales-zh-TW.ts +++ b/src/client/locales-zh-TW.ts @@ -121,6 +121,7 @@ export const zhTW: Record = { commit: '提交', commitError: '提交失敗', branch: '分支', + worktree: '工作樹', checkoutError: '切換分支失敗', history: '歷史', changes: '變更', diff --git a/tests/locales.spec.ts b/tests/locales.spec.ts index 56e0750..fcfad45 100644 --- a/tests/locales.spec.ts +++ b/tests/locales.spec.ts @@ -6,7 +6,7 @@ * interpolation. */ import { afterEach, describe, expect, it } from 'vitest' -import { LOCALE_NS, attachBetterLocale, attachLocale, en, isZh, ja, relativeTime, t, zh } from '../src/client/locales.ts' +import { LOCALE_NS, attachBetterLocale, attachLocale, en, isZh, ja, relativeTime, t, zh, de, fr, pt, ko, ar, hi, id as idDict, tr, vi, th, ru, it as itDict, nl, sv, pl, zhHK, zhTW, zhMO } from '../src/client/locales.ts' /** Minimal structural fake of the DSH LocaleService face the sidebar uses. */ class FakeLocale { @@ -111,6 +111,18 @@ describe('locales (DSH i18n following)', () => { it('keeps the ja dictionary key-set-equal to zh', () => { expect(Object.keys(ja).sort()).toEqual(Object.keys(zh).sort()) }) + + it('keeps every shipped third-language dictionary key-set-equal to zh', () => { + // The third-language dicts are typed `Record` via + // an `as` cast (unchecked by tsc). This test catches missing/extra keys + // introduced when a zh key is added without updating every language. + const thirdLangs = { + de, fr, pt, ko, ar, hi, idDict, tr, vi, th, ru, itDict, nl, sv, pl, zhHK, zhTW, zhMO, + } + for (const [lang, dict] of Object.entries(thirdLangs)) { + expect(Object.keys(dict as Record).sort(), lang).toEqual(Object.keys(zh).sort()) + } + }) }) /** Minimal fake of the better-locale override store (the subset t()/isZh() read). */