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
行为完全不变。
This commit is contained in:
HuanLinOTO committed 2026-08-23 00:52:20 +08:00
1 parent d9b8f15d9e
commit 7ceee777b4
9 files changed
+607 -6

No files matched your search

+3
View File
@@ -141,6 +141,9 @@ importers:
'@deepseek-ai/dsh-tools':
specifier: 0.1.1-rc.1
version: 0.1.1-rc.1(5493e0ab460eb504a0593977b284c2a8)
'@huanlin/dsh-plugin-better-locale':
specifier: link:D:/Projects/deepseek-harness/dsh-plugin-better-locale
version: link:../dsh-plugin-better-locale
'@playwright/test':
specifier: ^1.62.1
version: 1.62.1