Passer au contenu principal
2

dsh-zh-cn

2189166478-bot/dsh-zh-cn

Translates the interfaces of installed DSH plugins into Chinese with an offline dictionary and a DOM translation layer, toggleable in settings.

Installer

dsh plugin --profile web add github:2189166478-bot/dsh-zh-cn

README

dsh-zh-cn · 中文汉化插件(DSH 插件界面汉化)

把 DeepSeek Harness(DSH)里已安装插件的英文界面换成中文。

很多第三方 DSH 插件只写英文:插件名、说明、按钮、菜单、开关提示全是英文。这个插件带一份离线中文词典,在页面上做整串精确替换;打开开关就汉化,关掉立刻恢复原文。

装好之后在「设置 → 汉化」里开关;插件市场「已安装」列表里的插件名与说明会变成中文。

特性

  • 离线:词典在构建时就打进客户端代码,运行时零联网,不调用任何翻译 API
  • 可开关:「设置 → 汉化」里有开关,默认开启;关掉按原文逐个还原
  • 不乱翻:只替换整串命中词典的文本(允许忽略首尾标点、…、项目符号、大小写);聊天正文、代码块、输入框、编辑器(Monaco / xterm / CodeMirror)一律不碰
  • 覆盖广:随包附 4700+ 条词条,来源是所有带 dsh.client 的已装插件(40 个)的客户端字符串 + 人工 UI 词表 + 插件中文名
  • 能扩展:词典是纯 JSON,改完跑一条命令就能重建

安装

要求:DSH >= 0.2.0-rc.1(Web 界面)。

git clone https://github.com/2189166478-bot/dsh-zh-cn.git

然后在 DSH 里让插件管理器安装这个目录(target 用绝对路径):

plugin_manager({ action: "install_bundle", target: "D:/path/to/dsh-zh-cn" })

装完如果界面没出现「汉化」,重启一次 DSH。

插件用 link: 方式安装,移动或删除这个目录会让插件失效,重新 install_bundle 指向新路径即可。

使用

  • 开关:设置 → 汉化 → 启用汉化
  • 面板里还能看到:词典条数、本次已替换的界面文本数、「重新扫描当前页面」按钮(改完词表或打开新页面后手动扫一遍)
  • 开关状态存在浏览器的 localStorage(键名 dsh-zh-cn:enabled),默认开启

工作原理

  1. 构建期:extract_corpus.py 从 ~/.dsh/profiles/<profile>/node_modules 里所有带 dsh.client 的包中抽出英文字符串字面量;translate_bing.py 调用微软 bing 的批量翻译端点(免费、无需 key)翻成中文;再叠一份人工词表。结果写进 dictionary.json。
  2. 打包:build_bundle.py 把词典合并(dictionary.json → glossary.json → curated.json,后者覆盖前者)、过滤垃圾条目,替换进 client.template.js 的 __DICT__ 占位,产出 client.js。
  3. 运行时:client.js 用 MutationObserver 监听 DOM,对文本节点与 placeholder / title / aria-label / alt / aria-description 做整串查表替换;命不中就不动。渲染到 Shadow DOM(Web Component)里的内容也会被扫到。
  4. 还原:每个被改过的节点都记着原文,关开关时逐个写回。

扩展词典

# 1. 加了新词 → 直接重建
python build_bundle.py

# 2. 插件更新后冒出一堆新英文 → 重新抽词 + 增量翻译 + 重建
python extract_corpus.py          # → corpus.json
python translate_bing.py          # → 增量补进 tr_cache.json / dict.json
python build_bundle.py

改完把 package.json 的版本号 +1,在 DSH 里卸载再安装即可(客户端半边会热加载)。

三种词典文件的分工:

文件用途
dictionary.json机翻 + 人工整理后的主词典(4700+ 条),一般不用手改
glossary.json通用 UI 词(按钮、菜单项、字段名),优先级更高
curated.json逐条覆盖:插件中文名、某句具体文案,优先级最高

想修某条翻译:在 curated.json 里加 "英文原文": "中文",重建即可。

已知限制

  • 只做整串精确匹配:带变量的句子(Save 3 changes、3 of 25 selected)不翻,保持英文
  • 机翻难免有生硬的地方,遇到直接在 curated.json 覆盖那一条
  • 只作用于 DSH 的 Web 渲染层:<iframe> 或 canvas 里画出来的文字(画布、终端输出)翻不到
  • 极少数每次重绘都重写文本的标签可能保持英文
  • 词典条目是从各插件客户端代码里抽出的 UI 文案,版权归各插件作者;本仓库只提供译文映射

开发

dsh-zh-cn/
├── package.json         # dsh.bundle / dsh.client 声明
├── index.js             # 宿主半边(空实现)
├── cordis.patch.yml     # 插入插件条目 id: zh-cn
├── client.template.js   # 客户端半边源码(__DICT__ 占位)
├── client.js            # 构建产物(词典已内嵌,别手改)
├── icon.svg
├── build_bundle.py      # 合并词典 → client.js
├── extract_corpus.py    # 从已安装插件抽英文串
├── translate_bing.py    # 批量机翻(构建期用)
├── dictionary.json      # 主词典
├── glossary.json        # 人工 UI 词表
└── curated.json         # 逐条覆盖

License

MIT


English: dsh-zh-cn is a localization plugin for DeepSeek Harness. It ships an offline Chinese dictionary and translates English UI strings of installed plugins at runtime via a MutationObserver (exact whole-string matches only; chat content, code blocks and inputs are skipped). Toggle it in Settings → 汉化; disable to restore the original text. To add or fix entries, edit glossary.json / curated.json and run python build_bundle.py.

Plugins associés