Renders installed DSH plugin titles and descriptions in Simplified Chinese: at startup it translates the plugins the local JSON cache lacks through the harness LLM service, then projects { en, zh } metadata for resolveText() to render — no DOM changes, no third-party API.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Daneel0001/dsh-plugin-zh-cn
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
把 DeepSeek Harness(DSH)已安装插件的显示名与描述,在启动时翻译成简体中文并缓存到本地。 翻译后端可以选:微软翻译免费接口(默认,不用账号、不用 Key)、任意 OpenAI 兼容 API,或 DSH 里的模型。
**没有硬编码词典,也不碰 DOM。**译文按 { en, zh } 投给 DSH 自己的 resolveText(),
所以在英文界面下显示结果与安装前逐字相同。
安装前 billion-context A context-compression plugin — small context windows…
安装后 十亿级上下文插件 小上下文窗口即可容纳超大仓库上下文
English:
dsh-plugin-zh-cnrenders installed DSH plugin titles and descriptions in Simplified Chinese. At startup it reads a local translation cache, projects{ en }plugin metadata into{ en, zh }so DSH's ownresolveText()renders Chinese, and translates any installed plugin the cache does not know yet — with the free Bing translator (default, no account or key), any OpenAI-compatible API, or DSH's built-inllmservice. No built-in dictionary, no DOM manipulation. See English summary.
效果与保证
| 界面语言 | 插件标题 | 插件描述 |
|---|---|---|
| 中文 | 中文标题 | 中文描述 |
| English / 其它 | 与安装前逐字相同 | 与安装前逐字相同 |
- 零 DOM 改动:不新增节点、不改 class、不改内联样式、不改任何文本节点。
- 零开关影响:右侧启用/停用走
entry.enabled与pluginManager.setPluginEnabled, 和元数据毫无交集。 - 不动别人的翻译:元数据里已经带
zh的插件(含全部官方内置插件)一律跳过, 一个字节都不改。已经自带中文的内置选项(「语音输入」「终端」……)自然不会被碰。 - 失败即原样:翻译后端报错、超时、网络断开、返回非法 JSON、译文不是中文 —— 任何一条 都只让该插件保留英文,并记一条警告,设置界面不会崩溃、不会白屏。
- 严格模式(默认开):名称与描述都拿到译文才写入缓存,绝不出现半中半英。
- 可完全卸载:插件被禁用或移除时,注入层通过
ctx.effect的清理回调原样撤销。
安装
从插件市场安装(推荐)
在 DSH 桌面版的「插件」页点「添加插件」,填入本仓库地址:
github:Daneel0001/dsh-plugin-zh-cn
装好后 重启 Harness。客户端模块图是在渲染页面时写进 index.html 的,
仅刷新页面不会把新插件送进已打开的窗口。
手动安装
# 1. 把 tgz 放进 profile 的 plugins 目录
Copy-Item .\dsh-plugin-zh-cn-<version>.tgz "$env:DSH_PROFILE_DIR\plugins\"
# 2. 在 <profile>/package.json 里登记两处
# dependencies: "dsh-plugin-zh-cn": "file:<profile>/plugins/dsh-plugin-zh-cn-<version>.tgz"
# dsh.profile.bundles: 追加 "dsh-plugin-zh-cn"
# 3. 用 pnpm 真正安装(这一步才会写入 lockfile 与 .modules.yaml)
node "$pnpm" install --dir "$env:DSH_PROFILE_DIR"
必须走第 3 步。 只把 tgz 放进
plugins/、再手工复制目录到node_modules/是不够的: DSH 组合 profile 时以 pnpm 的安装结果为依据,未进入pnpm-lock.yaml/node_modules/.modules.yaml的包会被静默跳过。
生效时机
换了插件版本之后必须重启 DSH。 实测在运行中的实例里用「禁用 → 启用」热重载插件,不会让 Node 重新加载模块(ESM 模块缓存命中),跑的还是旧代码;只有重启 Harness 才会真正换版本。
- 第一次启动:已缓存过的插件立刻就是中文;新发现的插件在后台翻译, 本次启动仍显示英文。
- 第二次启动:上次翻好的插件直接命中缓存,一个请求都不发。
- 想在第一次启动里就看到中文:把一份现成的
local-cache.json交给seedFiles(格式见examples/local-cache.example.json)。 - 也可以在后台翻译完成后切换一次设置页或刷新窗口:注入层是实时查缓存的, 重新取数就能看到中文,不必重启。
工作原理
1. 拦截点:数据层,而不是 DOM
DSH 的插件列表渲染链是(均为 app.asar 内官方源码):
客户端 UI 组件 PluginInventorySettingsTab
└─ ctx.remote.pluginInventory.list() dsh-client-ui-settings-plugin-inventory/lib/client.js
└─ 宿主服务 pluginInventory.list() dsh-host-plugin-inventory/lib/index.js
└─ readPluginInventory(ctx)
├─ ctx.loader.entries() ← 「已安装」的插件行
└─ ctx.get('pluginPackages').metaOf(name, base) → { title, description }
而屏幕上真正出现的文字,只在客户端这一个出口被解析:
// dsh-client-locale/lib/client.js
resolveText(text) {
if (typeof text === 'string') return text;
return this.fallbackChain(this.snapshot.active)
.reduceRight((resolved, locale) => text[localeKey(locale)] ?? resolved, text.en);
}
LocalizedText = string | { en: string, [locale]: string } —— 中文界面取 zh,英文界面取 en。
这正是官方内置插件显示「智能体团队」而英文界面仍显示原文的机制。
所以本插件只做一件事:在数据层把 meta.title / meta.description 从 { en } 补成 { en, zh }。
包装两处返回值,任一生效即可:
| 目标 | 位置 | 说明 |
|---|---|---|
pluginPackages.metaOf |
dsh-app-boot 的 cordis Service |
readPluginInventory 的直接取数处 |
pluginInventory.list |
dsh-host-plugin-inventory 的 Remote 网关 |
界面调用的入口,兜底 |
为什么不用 MutationObserver 改文本节点?
事后补救。React 每次重渲染都会把改过的文本节点覆盖回去,需要持续对抗; 而且一旦插件的元数据或 DOM 结构稍有变化就容易误伤布局。 数据层注入则从根上解决问题:DOM 从头到尾就没有被改过,中文是 DSH 自己渲染出来的。
2. 缓存
运行时缓存位置(原子写入:先写 .tmp 再 rename):
<DSH_PROFILE_DIR>/dsh-plugin-zh-cn/local-cache.json
# 例如 C:\Users\<你>\.dsh\profiles\desktop\dsh-plugin-zh-cn\local-cache.json
{
"version": 2,
"generator": "dsh-plugin-zh-cn",
"updatedAt": "2026-10-16T10:43:30.000Z",
"entries": {
"billion-context": {
"en": { "title": "billion-context", "description": "A context-compression plugin — …" },
"zh": { "title": "十亿级上下文插件", "description": "小上下文窗口即可…" },
"model": "deepseek/deepseek-chat",
"translatedAt": "2026-10-16T10:43:30.000Z"
}
}
}
- 增量:按包名索引;
en是英文指纹,指纹没变就一个请求都不发,变了才重译。 - 只增不减:每次写盘都是「读旧 → 合并新条目 → 原子替换」, 历史条目(包括已经卸载的插件)永远保留,方便你回查和手工编辑。
- 兼容旧格式:扁平词表
{ "<包名>": { "title": "…", "description": "…" } }会被当作中文译文直接吸收,可以作为初值平滑迁移。 - 多来源合并:随包发布的
local-cache.json与seedFiles都是初值, 运行时缓存里的同键条目优先,绝不会被清空覆盖。
3. 翻译
backend 决定用哪个后端,默认 bing(微软翻译免费接口,不用账号、不用 Key):
| backend | 说明 | 需要的配置 |
|---|---|---|
bing(默认) |
微软翻译免费网页接口(cn.bing.com) |
无 |
api |
任意 OpenAI 兼容接口 | apiBaseUrl + apiKey + apiModel |
llm |
DeepSeek 账号:用「设置 → 模型」里选中的模型 | 无 |
bing 把名称与描述分成两次请求直接拿到译文(不需要提示词);api / llm 一次请求
同时把两者交给模型,要求它只回一个 JSON:
系统提示词(要点)
只输出 {"name":"<中文名称>","desc":"<中文描述>"},不要解释、不要 Markdown 围栏
名称 ≤ 12 个汉字;描述 ≤ 40 个汉字、一句话
API / Token / MCP / SSH / Git / JSON / LLM 等专有名词照抄不译
拿到译文后会先校验再落盘:api / llm 必须能解析出 JSON,且译文必须真的含中文;
bing 直接取返回文本。不满足就当失败,保留英文原文。
配置
插件导出 Config(Schemastery schema)用于校验配置;2.2.0 起还带浏览器侧卡片,
在「设置 → 插件」→ dsh-plugin-zh-cn 的详情页里选翻译后端
(保存会写回 profile 的 cordis.patch.yml,下一轮启动生效)。
卡片上是三行:
| 行 | 可改的字段 |
|---|---|
| 微软翻译 | 翻译页地址(一般不用改) |
| 自定义 API | Base URL / API Key / 模型名 |
| DeepSeek 账号 | 没有字段 —— 直接用「设置 → 模型」里选中的模型 |
其余字段也可以直接写进 profile 的 cordis.patch.yml: |
- id: zh-cn-plugin-locale
name: dsh-plugin-zh-cn
config:
enabled: true # 总开关
strict: true # 名称+描述都有译文才写入缓存
backend: bing # bing(微软翻译,免费)| api(OpenAI 兼容)| llm(DSH 里的模型)
bingEndpoint: '' # 留空 = https://cn.bing.com
apiBaseUrl: '' # 留空 = https://api.deepseek.com/v1(含 /v1)
apiKey: '' # backend: api 时必填
apiModel: '' # 留空 = deepseek-chat
timeoutMs: 60000 # 单条翻译超时(描述很长的插件要给足时间)
maxTokens: 4096 # 单条翻译输出上限(仅 api / llm 用)
provider: '' # 兼容旧配置,卡片已不暴露;llm 后端留空 = 跟随「设置 → 模型」
model: '' # 同上
fallbackToAccount: true # 同上;llm 后端本身就是账号渠道,默认开启
retryDelayMs: 180000 # 仅 backend: llm;没等到可用模型/服务时,隔多久自动重试一轮(毫秒)
cacheFile: '' # 留空 = <profile>/dsh-plugin-zh-cn/local-cache.json
seedFiles: [] # 额外的缓存初值(绝对路径),只合并、不覆盖
maxPerStart: 500 # 每次启动最多新翻几个插件(默认实质上不限,一个全新 profile 也就几百条)
delayMs: 200 # 两条翻译之间的间隔
saveEvery: 8 # 每翻译成功几条落一次盘,中途退出不丢已完成的部分
retry: 3 # 每条最多尝试几次(设为 1 即关闭重试)
debug: false # 把每条翻译结果写进 debug 日志
模型解析顺序(仅 backend: "llm" 时适用;前一个拿不到才用下一个):
- config 里的
provider+model(显式指定); - 「设置 → 模型」里选定的默认模型;
fallbackToAccount: true(默认)时,回退到 DSH 账号渠道的deepseek-account/deepseek-flash。
注意:DSH 账号渠道只对自己允许的目的地签发 token(resolveToken(endpoint)),
插件发起的请求可能得到 ACCOUNT_SIGN_IN_REQUIRED(实测 dsh-kb-lite 必失败)。
遇到这种情况改用默认的 backend: "bing" 或 backend: "api" 即可。
fallbackToAccount 是 2.1.0 加的:以前启动早期读不到默认模型,整轮翻译会一条都不翻(缓存里的
lastRun 停在 model: "(未就绪)"、translated: 0)。现在第 3 级兜底保证能翻;实在没模型时,
插件会按 retryDelayMs 自动重试,不再「本轮放弃、等下辈子启动」。
安全与副作用
- 只读其它插件的
package.json;不写入任何其它插件的目录。 - 唯一会写的文件是
local-cache.json(及其.tmp),位置就在插件自己的数据目录。 - 联网范围只有翻译请求本身:
bing→cn.bing.com(可用bingEndpoint换地址);api→apiBaseUrl;llm→ DSH 自己的模型调用。不执行外部命令。 - 不改 profile 配置:插件页卡片的「保存」走 DSH 自己的
configForms/ configEditor, 由 DSH 写进cordis.patch.yml;插件自己只写local-cache.json。 - 所有异常都被捕获并降级为一条
warn日志,不会影响 DSH 启动。
卸载
在插件设置里关掉「插件简体中文化」,然后重启。
注入层随插件 fiber 一起卸载(ctx.effect 清理回调会还原被包装的两个方法)。
运行时缓存 local-cache.json 会留在 profile 里,想彻底清干净就手动删掉
<DSH_PROFILE_DIR>/dsh-plugin-zh-cn/ 目录。
开发
npm run check # 静态自检:清单、语法、可导入性,以及「不许硬编码词典」
npm run check:syntax # 只做语法检查
npm test # 60 项验收测试(含 8 项 apply 集成测试)
npm test 零依赖,在源码目录里就能跑完 60 项(含 8 项 apply 端到端集成测试)。
测试全部在系统临时目录里工作,永远不会碰真实 profile。
导出:apply、resolveConfig、DEFAULTS、inject、name,以及供测试使用的纯函数
resolveCacheFile、nearestProfileDir、collectInstalledPlugins、
extractEnglish、alreadyLocalized、resolveSelection、runTranslationPass。
目录结构
lib/index.js 插件入口:读缓存 → 装注入 → 异步扫描翻译
lib/client.js 浏览器侧:插件详情页的「翻译模型」卡片(卡片行 + 编辑,2.2.0+)
lib/inject.js 数据层注入:包装 metaOf / pluginInventory.list(实例 + 原型,动态 this)
lib/cache.js local-cache.json 的读取、合并、原子写
lib/translate.js 三种后端:Bing 免费翻译 / OpenAI 兼容 API / DSH llm;提示词、JSON 解析与中文校验
lib/text.js LocalizedText 工具与「值不值得翻译」的判定
locale/*.json 本插件自身的语言字典(自举)
cordis.patch.yml bundle 补丁:把插件行插进组合配置树
test/acceptance.mjs 60 项验收测试(另有 1 项按环境跳过)
scripts/check.mjs 静态自检(CI / prepack)
examples/ local-cache.json 格式示例
English summary
dsh-plugin-zh-cn renders the titles and descriptions of installed DSH plugins in
Simplified Chinese.
At startup the host half:
- reads
<profile>/dsh-plugin-zh-cn/local-cache.jsonsynchronously, so the first render already has Chinese for everything it has seen before; - wraps
pluginPackages.metaOfandpluginInventory.list— the exact functions the settings UI reads plugin metadata through — projecting{ en }into{ en, zh }. DSH's ownresolveText()then renders Chinese on a Chinese UI and the original English everywhere else. No DOM node, class, style, or the enable/disable toggle is touched. - asynchronously scans the installed plugin list and translates any plugin the cache does
not know yet, with one of three backends (
backend):bing(default — the free Bing translator endpoint, no account or API key),api(any OpenAI-compatible endpoint:apiBaseUrl+apiKey+apiModel), orllm(DSH's built-inllmservice, default model fromagentDefaultModel).api/llmsend name and description in one request and expect{"name": …, "desc": …}; results are merged back into the cache.
No built-in dictionary. The only network traffic is the translation request itself
(cn.bing.com, your apiBaseUrl, or DSH's own model route). Any failure — timeout, bad
JSON, non-Chinese output, network or model error — leaves the English original in place and
logs a warning.
许可
Links
More in this category
zhu1090093659/dsh-web#packages/dsh-task-board★ 10703
Task board for the dsh web GUI: a sidebar multi-column kanban whose cards run in real DSH agent sessions and can also be scheduled with cron expressions, executed host-side even with the browser closed.
zhu1090093659/dsh-web#packages/dsh-web-all★ 10703
Plugin and skin collection for the DSH Web UI: task board, Git graph, right-side panel, remote mobile UI, pet, live token stats, and a skin center.
ccch1mneyyy/dsh-TUI★ 8557
Claude Code-style full-screen terminal UI: pixel-whale header, live status line, and streaming thought expansion.
MeteorNOX/DeepSeek-Balance-Whale-Widget★ 7523
A fixed-corner whale widget for the DSH web GUI — balance, today's usage and per-turn cost with peak/off-peak pricing, editable balance-alert and daily-budget bubbles, a module-based custom bubble queue with A/B weighted choices and random lines or images, 30+ vendor templates (OpenAI, OpenRouter, Kimi, SiliconFlow, Ark, Zhipu, MiniMax and more) with per-model balance and subscription quota, plus task-end sound, imported audio, custom roles and a resource manager. Local-only, no telemetry.
omdsh-dev/DSH-better-sidebar★ 5405
Full sidebar workbench with file rendering and editing, terminal, Git, and subagents; third-party plugins can register new tabs.
omdsh-dev/dsh-genui★ 1091
Interactive UI components rendered inline in replies: layout, charts, forms, quizzes, mermaid, 3D scenes, and an action event loop back to the model.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.