HuanLinOTO
9410e5bb2a
fix(i18n): add worktree translation to all 19 third-language dicts ( #285 )
...
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<keyof typeof zh, string> 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
2026-08-23 20:58:33 +08:00
HuanLinOTO
38dc807d15
refactor(i18n): 覆盖只在 DSH active=en 时生效(借用英文槽位)
...
better-locale 的覆盖本质上是借用 DSH 的英文槽位来渲染第三语言:
- store.getOverride(dshActive, ns, key) 改为只在 dshActive === 'en'
时返回覆盖文本;DSH 在 zh 下覆盖完全惰性(保持原生 zh)
- 新增 store.isOverrideActive(dshActive):返回 active !== undefined
&& dshActive === 'en',供 better-sidebar 的 isZh() 判断
- isZh() 改用 isOverrideActive(dshActive) 判断(仅在 DSH=en 且有
override 时返回 false),zh 下返回 true
- LanguageSwitcher 接收 dshActive prop,选了非 native 且 DSH 非 en
时显示「请将 DSH 切换到英文以查看 [语言名]」提示
- 新增 switchToEnHint copy key(zh + en)
- 测试:better-locale +3 store tests(en-only / inert on zh /
isOverrideActive),+1 patch test(inert on zh);better-sidebar
+1 locales test(override inert while DSH on zh),FakeBetterLocale
加 isOverrideActive 方法
2026-08-23 01:42:01 +08:00
HuanLinOTO
7ceee777b4
feat(i18n): 接入 @huanlin/dsh-plugin-better-locale 支持 ja 覆盖
...
新增 ja 词典(src/client/locales-ja.ts,326 keys,与 zh key-set-equal),
通过可选 peer @huanlin/dsh-plugin-better-locale 接入第三语言覆盖:
- locales.ts: 新增 attachBetterLocale(store) + ja dict export;t() 先查
store.getOverride(active, 'betterSidebar', key),命中则返回覆盖文本,
否则走原 zh/en 链;isZh() 在 override 激活时返回 false
- client/index.tsx: apply 中 ctx.get('betterLocale') 取得 override store
(optional,未安装时为 undefined),attachBetterLocale 注入 t();同时
register('betterSidebar', { ja }) 把 ja 词典注册进 better-locale 的
store,让外部 ctx.locale.lookup 调用者也能拿到 ja 文本
- Sidebar.tsx: 新增 betterLocaleActive uSES 订阅 store.subscribe,覆盖
切换时全树重渲染(DSH locale 的 active 字段不变,既有 localeRevision
uSES 不会触发)
- package.json: @huanlin/dsh-plugin-better-locale 加为 optional peer
+ devDep link
- tests/locales.spec.ts: 新增 7 个 better-locale override 测试(命中/
fallback/detach/interpolate/ja dict 完整性 smoke check)
未安装 better-locale 时 ctx.get 返回 undefined,整段为 no-op,zh/en
行为完全不变。
2026-08-23 00:52:20 +08:00
Menghuan1918
9c5293c94b
feat: 界面文案跟随 DSH 的 i18n(ctx.locale 语言偏好、实时切换、词典入注册表)
2026-08-13 00:43:28 +08:00