dsh-selection-translate
yyyl99/dsh-selection-translate
Select text in a conversation and click the 译 badge at the bottom-right corner of the selection. A card opens below it with the translation, and for a single word also phonetics, part-of-speech meanings and bilingual examples. The original text can be read aloud. No API key or configuration is needed.
インストール
dsh plugin --profile web add github:yyyl99/dsh-selection-translateREADME
划词翻译
在 DeepSeek Harness 的对话里框选任意一句文本,选区右下角会出现一个小圆点(中文界面显示「译」,英文界面显示「A」)。点一下,圆点下方弹出翻译小窗:
- 句子:原文 + 译文(英汉互译);
- 单个英文单词:词典式词条 —— 词头、音标、每个词性最多两条中文释义,每个词性下配一条双语例句;
- 每段英文后面都有小喇叭,点一下朗读该段(原文、译文或词头)。
不会自动翻译任何内容,弹窗也不改动对话;在小窗内选中文字不会触发新的翻译。
安装
在插件市场 / Discover 里搜索 selection translate,或打开 Plugins 页面,在添加插件输入框里填:
github:Yyyl99/dsh-selection-translate
已安装 DSH 命令行工具的机器也可以执行:
dsh plugin add github:Yyyl99/dsh-selection-translate
装一次,Desktop 与 dsh web 都能用。
用法
- 用鼠标框选对话里的一句话或一个英文单词;
- 选区右下角出现小圆点,点它;
- 小窗在圆点下方展开;上排可以切「自动 / 中文 / English」方向,右上是朗读与关闭;
- 点小窗外、按 Esc、或把选区滚出屏幕,小窗都会收起。
方向默认是「自动」:中文内容译成英文,其余译成中文;手动选过的方向会记住。
界面
小窗是不透明卡片:深色底加一档提亮、1px 描边、14px 圆角、较大投影,顶部有一个指向圆点的小尖角,与窗口边缘至少留 20px。高度随内容自适应,只有内容超出窗口时才在卡片内滚动。
- 头部:查词时显示词头 + 音标(带喇叭),整句时显示
翻译小标题;右侧关闭按钮; - 整句:原文(次要色)→ 细分隔线 → 译文(更大更深);
- 单词:按词性的释义列,每个词性下缩进一条例句,源词在例句里高亮;词典完全没有该词条时,才用一行机翻作为兜底释义;
- 例句来源:优先用词典自带的句子,按语义挑与该词性对得上的;仍然缺例句的词性,才请当前窗口使用的模型按词性补一句 —— 对得上就沿用原句,对不上才新写,新写的句子带
AI角标(会消耗 token,见下节); - 代码标识符(如
diagKey,机翻会原样返回,看着像「翻不了」):拆成单词后翻译,并以词条小卡列出每个部分的释义; - 底部:
自动 / 中文 / English方向胶囊,以及引擎名(查词时再带一个词典标记)。
token 消耗
查词时,如果词典自带的例句不足以覆盖卡片上显示的每个词性,插件会用当前窗口正在使用的模型为缺少例句的词性补写一句英文例句(连同中文意思),这类句子在卡片上带 AI 角标。
- 何时会调用模型:只有「这个词性在词典语料里找不到能对上的句子」时才会调用;语料够用时一次模型请求都不会发;
- 单次规模:一次请求里包含词头、卡片上显示的释义、若干条候选例句,约 500–800 个输入 token,输出 100–200 个 token;
- 缓存:同一个词 + 同一组释义的结果在内存里保留 1 小时,重复查同一个词不会重复扣费;进程重启后缓存清空;
- 模型来自哪里:跟随窗口当前选择的模型(设置里选的 provider/model),不额外配置 key,也不额外计费到别处;
- 不想要这项功能:把窗口模型切换成一个不可用的模型,插件会静默跳过补写,只显示词典里已有的例句(卡片不会有
AI角标),翻译与朗读不受影响。
朗读
优先用窗口自带的语音合成;窗口没有可用语音时,改由宿主通过 Windows SAPI 朗读。正在朗读的那段,喇叭会变成停止方块;点另一段会先停掉上一段。
隐私
翻译发给 Bing(edge.microsoft.com),查词发给有道(dict.youdao.com,未收录时回退 dictionaryapi.dev)。选中的文本不写入磁盘;本地只保存方向选择,以及一小段用于排障的诊断记录(%TEMP%/dsh-selection-translate.log,只记时间、阶段、尺寸,不记文本)。
许可
MIT 许可证,详见 LICENSE。
English
Select text in a conversation and click the 译 badge at the bottom-right corner of the selection to open a translation card below it. The card shows phonetics, meanings and examples (one bilingual example under each part of speech), and can read any English text aloud. Translation is English ↔ Chinese, on demand only.
Corpus first: the dictionary's own sentences are matched to senses by meaning; only senses left without a sentence go to the model the window already runs on, and those sentences carry an AI tag.
That fallback costs tokens: one request per word (roughly 500–800 input, 100–200 output tokens) and only when the corpus cannot cover a sense; results are cached in memory for one hour. With no usable window model the step is skipped silently and only corpus sentences are shown.
Text leaves the machine only to reach Bing Translate and Youdao (fallback: dictionaryapi.dev).
Install from the plugin market, from the Plugins page with github:Yyyl99/dsh-selection-translate, or with dsh plugin add github:Yyyl99/dsh-selection-translate.