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
2026-08-23 00:52:20 +08:00
parent d9b8f15d9e
commit 7ceee777b4
9 changed files with 607 additions and 6 deletions
+5
View File
@@ -99,6 +99,7 @@
"@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
"@deepseek-ai/dsh-subagent": "^0.1.0-rc.8",
"@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
"@huanlin/dsh-plugin-better-locale": "^0.1.0",
"cordis": "^4.0.0-rc.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
@@ -106,6 +107,9 @@
"peerDependenciesMeta": {
"cordis": {
"optional": true
},
"@huanlin/dsh-plugin-better-locale": {
"optional": true
}
},
"dependencies": {
@@ -154,6 +158,7 @@
"@deepseek-ai/dsh-settings": "0.1.1-rc.1",
"@deepseek-ai/dsh-subagent": "0.1.1-rc.1",
"@deepseek-ai/dsh-tools": "0.1.1-rc.1",
"@huanlin/dsh-plugin-better-locale": "link:D:/Projects/deepseek-harness/dsh-plugin-better-locale",
"@playwright/test": "^1.62.1",
"@types/node": "^24.0.0",
"@types/react": "~18.3.1",