feat(i18n): 目录项与 shell 预设文案词典化,兜底错误条改皮肤令牌链 - #535
Merged
Conversation
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
force-pushed
the
feat/i18n-catalog-names
branch
from
September 3, 2026 12:01
4de321e to
e8834bd
Compare
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 剔除。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更一:目录项 name 与 shell 预设 desc 词典化(e970ae8)
推荐插件目录(
src/client/plugins-tabs.ts15 条 +src/client/plugins-viewers.ts4 条)的name与src/client/shell-presets.ts的 dsh-desktopdesc原是裸中文,经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 名对齐既有
pluginXxxDesc→pluginXxxName)15 个 tab 名 + 4 个 viewer 名 + 1 个
presetDshDesktopDesc。三处对齐说明:locales.ts,值 = 原硬编码中文逐字迁移,zh 用户零变化)+ en(locales.ts)+ ja(locales-ja.ts)按要求同步;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.css的var(--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 弹层/卡片层级)→ 页面基础底两跳链;--dsw-alias-*皮肤即被重主题(指南 §12「无硬编码颜色」)。指南 §12 未提及该兜底条、
tests/theme.spec.ts只断言effectiveTokenValue语义,均无需跟随。spec 跟随改动(均为本流行为变更的跟随,无削弱)
tests/plugin-list.spec.tsentry.name.length→textOf(entry.name).length;头注释补「localized name」tests/add-plugin-modal.spec.tsx'dsh-sentinel 唤醒系统'等裸中文名断言 →textOf(officeEntry.name)/textOf(sentinelEntry.name)(按 id 取目录项)t()渲染 en 文案,裸 zh 字面量必然失配;改为从目录数据解析,与既有 officeEntry 模式一致tests/shell-presets.spec.tspreset.desc.length→textOf(preset.desc).length验证(全实跑)
pnpm install✅ /pnpm typecheck✅(干净无输出)/pnpm build✅ /pnpm check:consumer-types✅(对外类型面未动,两 pass 干净)pnpm test:118 文件全绿,1241 passed + 9 skipped——含locales.spec.ts词典 parity 硬门禁、theme.spec.ts、shell-presets.spec.ts、builtins.spec.ts、plugin-list.spec.ts、add-plugin-modal.spec.tsx@deepseek-ai/dsh@0.1.2-alpha.5,PATH=/tmp/dsh-alpha-bin/... pnpm test:mount):17 passed / 1 failed——失败仅为desktop-layout.e2e.ts的 workspace 弹窗(Select Workspace Directory/选择工作区目录对话框 5s 未现)超时,属任务书已知本机环境问题;mount.e2e.ts8/8 全过(含全部内置 tab、终端懒加载 chunk、editor chunk 深扫),无错误条 / pageerror / console 错误。