Skip to content

feat(i18n): 目录项与 shell 预设文案词典化,兜底错误条改皮肤令牌链 - #535

Merged
Menghuan1918 merged 2 commits into
mainfrom
feat/i18n-catalog-names
Sep 3, 2026
Merged

feat(i18n): 目录项与 shell 预设文案词典化,兜底错误条改皮肤令牌链#535
Menghuan1918 merged 2 commits into
mainfrom
feat/i18n-catalog-names

Conversation

@Menghuan1918

Copy link
Copy Markdown
Collaborator

变更一:目录项 name 与 shell 预设 desc 词典化(e970ae8)

推荐插件目录(src/client/plugins-tabs.ts 15 条 + src/client/plugins-viewers.ts 4 条)的 namesrc/client/shell-presets.ts 的 dsh-desktop desc 原是裸中文,经 add-plugin-modal.tsx / SideCardSection.tsx 直渲。现完全镜像既有 desc 模式

  • PluginEntry.name / ShellPreset.desc 拓宽为 i18n 友好联合 string | (() => string)(联合的纯字符串臂即「原 name 值兜底」——未收录词典的条目渲染原文;t() 本身对缺失 key 返回 key 而非空,任何词典缺口都不会让名字变空白);
  • 目录数据带 () => t('pluginXxxName') 惰性求值;add-plugin modal 的渲染 / 搜索过滤 / aria-label、方案下拉的 preset desc 逐点解析(与 description 同款 typeof === 'function' 处理)。

新增词典 key(20 个,key 名对齐既有 pluginXxxDescpluginXxxName

15 个 tab 名 + 4 个 viewer 名 + 1 个 presetDshDesktopDesc。三处对齐说明:

  • zhlocales.ts,值 = 原硬编码中文逐字迁移,zh 用户零变化)+ enlocales.ts)+ jalocales-ja.ts)按要求同步;
  • 另 18 个 locales-*.ts 也补齐了真实翻译(de/fr/pt/ko/ar/hi/id/tr/vi/th/ru/it/nl/sv/pl/zh-HK/zh-TW/zh-MO)。这与任务描述的「其余单语文件不动」冲突,但 tests/locales.spec.ts 硬门禁要求每个已发布词典与 zh key 集完全相等(含非 ja 语言),只改 zh/en/ja 必然红;仓库先例 9cc642b 也是 19 文件全量补齐。故按硬门禁执行。

变更二:兜底错误条皮肤令牌链(4de321e)

src/client/index.tsx 宿主锚兜底错误条的 inline 硬编码色改为 var() 链(对齐 SideChatView.module.cssvar(--dsw-alias-button-info-label, var(--dsw-alias-accent-ink, #fff)) 模式),原注释保留并补充说明:

  • 文字/边框 → var(--dsw-alias-state-error-primary, #f2a1a1):仓库错误色事实标准(23 处在用:错误文字、color-mix 边框/底色);
  • 背景 → var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-base, #1b1b22)):抬升表面层(SideCardSection 弹层/卡片层级)→ 页面基础底两跳链;
  • 链尾保留原 hex:页面无任何皮肤令牌时与现状逐字节一致;有 --dsw-alias-* 皮肤即被重主题(指南 §12「无硬编码颜色」)。

指南 §12 未提及该兜底条、tests/theme.spec.ts 只断言 effectiveTokenValue 语义,均无需跟随。

spec 跟随改动(均为本流行为变更的跟随,无削弱)

spec 改动 理由
tests/plugin-list.spec.ts entry.name.lengthtextOf(entry.name).length;头注释补「localized name」 name 变为 string-or-function 联合,非空断言需先解析
tests/add-plugin-modal.spec.tsx 'dsh-sentinel 唤醒系统' 等裸中文名断言 → textOf(officeEntry.name) / textOf(sentinelEntry.name)(按 id 取目录项) 测试环境(jsdom en)下名字现经 t() 渲染 en 文案,裸 zh 字面量必然失配;改为从目录数据解析,与既有 officeEntry 模式一致
tests/shell-presets.spec.ts preset.desc.lengthtextOf(preset.desc).length desc 变为联合,非空断言需先解析

验证(全实跑)

  • pnpm install ✅ / pnpm typecheck ✅(干净无输出)/ pnpm build ✅ / pnpm check:consumer-types ✅(对外类型面未动,两 pass 干净)
  • pnpm test118 文件全绿,1241 passed + 9 skipped——含 locales.spec.ts 词典 parity 硬门禁、theme.spec.tsshell-presets.spec.tsbuiltins.spec.tsplugin-list.spec.tsadd-plugin-modal.spec.tsx
  • 挂载 lane(钉版 @deepseek-ai/dsh@0.1.2-alpha.5PATH=/tmp/dsh-alpha-bin/... pnpm test:mount):17 passed / 1 failed——失败仅为 desktop-layout.e2e.ts 的 workspace 弹窗(Select Workspace Directory/选择工作区目录 对话框 5s 未现)超时,属任务书已知本机环境问题;mount.e2e.ts 8/8 全过(含全部内置 tab、终端懒加载 chunk、editor chunk 深扫),无错误条 / pageerror / console 错误。

Catalog entry names (15 tab + 4 viewer) and the dsh-desktop shell preset
desc were raw hardcoded zh strings rendered straight into the add-plugin
modals and the title-bar scheme dropdown. Mirror the existing desc
pattern exactly: PluginEntry.name / ShellPreset.desc widen to the
i18n-friendly string-or-() =>-string union, the catalogs carry lazy
t('pluginXxxName') / t('presetDshDesktopDesc') lookups, and the
add-plugin modal (render, search filter, aria-labels) plus the scheme
SelectMenu resolve them like every other copy. The plain-string arm of
the union stays as the raw-name fallback, and t() itself never yields
empty text (missing keys render the key), so a dict gap can never blank
a name.

20 new dictionary keys added to zh/en (locales.ts), ja (locales-ja.ts),
and all 18 third-language dictionaries — tests/locales.spec.ts enforces
key-set equality against zh for every shipped dict (precedent: 9cc642b),
so the 'leave other locales-* untouched' shortcut would fail the hard
parity gate; real translations are provided instead.

Spec follow-ups (behavior change: names/descs now render through t()):
- plugin-list.spec.ts: name non-empty assertion resolves the union.
- add-plugin-modal.spec.tsx: sentinel/office name assertions resolve
  from the catalog (en locale in tests) instead of pinning zh literals.
- shell-presets.spec.ts: desc non-empty assertion resolves the union.
The host-anchor fallback diagnostic strip inlined hardcoded colors
(#f2a1a1 on #1b1b22). Route them through var() chains like the existing
SideChatView.module.css fallback pattern: text/border read
--dsw-alias-state-error-primary (the codebase's canonical error color,
23 existing usages) and the background reads
--dsw-alias-bg-layer-3,var(--dsw-alias-bg-base,...) (elevated surface,
then page base). The old hexes ride as the chain tails, so with no skin
tokens on the page the bar renders byte-identical to before, while any
--dsw-alias-* skin re-themes it (guide §12: no hardcoded colors). The
guide does not cover this strip and tests/theme.spec.ts asserts
effectiveTokenValue semantics only, so neither needs a follow-up.
@Menghuan1918
Menghuan1918 force-pushed the feat/i18n-catalog-names branch from 4de321e to e8834bd Compare September 3, 2026 12:01
@Menghuan1918
Menghuan1918 merged commit f8bb301 into main Sep 3, 2026
5 of 6 checks passed
@Menghuan1918
Menghuan1918 deleted the feat/i18n-catalog-names branch September 3, 2026 12:18
LiarCoder pushed a commit to LiarCoder/DSH-better-sidebar that referenced this pull request Sep 3, 2026
omdsh-dev#535(i18n catalog names)给 tests/add-plugin-modal.spec.tsx 新增
sentinelEntry 行时漏了 import;omdsh-dev#535 自身 CI run 被 cancel,omdsh-dev#536 带病
合入,main HEAD 7b5c7dd 的 typecheck/test 双红(本地 stash 复现一致:
TS2304 / ReferenceError: builtinTabPlugins is not defined,CI run
33754439466 failure)。补上与 plugin-list.spec.ts 同源的 import。

与本 PR 主题无关,仅为本流验证门(typecheck/test 全绿)所需的最小
main 修复,独立成 commit 便于 review 剔除。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant