dsh-plugin-text-translation:DSH 文本與文檔翻譯插件

前言

DSH 插件生態裏,文本翻譯不能只靠模型直接處理原始文件。遊戲腳本里常見顏色、換行、變量佔位符,字幕和長文檔又往往條目很多。直接翻譯容易破壞 \c[1]{player}、SRT 時間軸等結構。

dsh-plugin-text-translation 給 DSH Agent 提供一組可調度工具:先檢查文件,再提取可翻譯文本並遮罩標籤,最後把翻譯結果無損回填到原格式。翻譯編排仍由 DSH Agent 完成,插件負責提取與裝配。

這是什麼

dsh-plugin-text-translation 是 DeepSeek Harness(DSH)的文本與文檔翻譯插件,倉庫 owner 爲 1738348785,許可證爲 MIT,package.json 版本爲 1.0.0

它面向遊戲腳本與長文檔本地化,提供標籤防爆遮罩、多格式文本提取/切片、無損回填組裝能力。實測環境爲 DSH 0.1.0-rc.6,headless 與 web profile 均已驗證。

它不是完整翻譯系統:翻譯本身由 DSH Agent 編排完成,可配合 DSH subagent / subagent_fork / workflow 並行翻譯批次;插件負責提取與裝配兩個環節。

核心功能

標籤防爆遮罩

插件自動識別並保護常見本地化標籤與佔位符,翻譯後還原:

  • RPG Maker:\c[1]\v[1]\n
  • Unity/RichText:<color><b>
  • 變量佔位符:{player}{0}%s
  • Ren’Py 標籤

支持格式

遊戲腳本:

  • Mtool JSON
  • Translator++ XLSX/CSV
  • Ren’Py .rpy
  • SRT/ASS/VTT 字幕
  • Gettext .po

長文檔:

  • PDF
  • Word .docx
  • Markdown
  • HTML
  • TXT

DSH 集成

  • 註冊 inspect_text_fileextract_textassemble_text 三個工具。
  • 導出 dsh.bundle Manifest,並隨 dsh plugin 安裝加入 profile 的 bundle 層。
  • Python 引擎隨插件分發,安裝即用且無外部路徑依賴。
  • 可選依賴未安裝時,僅對應格式或獨立 LLM 流水線功能報錯,其餘功能不受影響。

運行時 peerDependencies 包括:

{
  "@deepseek-ai/cordis": "^4.0.1",
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
  "@deepseek-ai/schemastery": "^3.18.1"
}

安裝與啓用

從 GitHub 安裝

先確認目標 profile 可用,再執行:

dsh plugin --profile demo add github:1738348785/dsh-plugin-text-translation

安裝後,插件會加入當前 profile 的 bundle 層。

安裝到 web profile

如果要在 web profile 中看到該插件,安裝到 web

dsh plugin --profile web add github:1738348785/dsh-plugin-text-translation

然後重啓 web 並刷新頁面。

本地源碼安裝

本地源碼安裝/開發調試可以使用當前目錄:

dsh plugin --profile demo add ./dsh-plugin-text-translation

本地路徑安裝可能因 pnpm 符號鏈接/junction 與 Node ESM 真實路徑解析導致 ERR_MODULE_NOT_FOUND。Windows 下需要把依賴樹以 junction 暴露給插件目錄。

不安裝快速調試

也可以只加載插件的 patch 層做快速調試:

dsh --profile demo --patch ./dsh-plugin-text-translation/cordis.patch.yml

新 profile 初始化注意

首次把插件裝進新 profile 時,可能遇到以下兩個 DSH 環境問題。

  1. npm registry latest tag 可能指錯 @deepseek-ai/dsh-base 舊版 0.0.1-rc.1。需要顯式指定 0.1.0-rc.6
  2. pnpm 11 默認阻止依賴 build scripts。遇到 ERR_PNPM_IGNORED_BUILDS 時,把 pnpm-workspace.yamlallowBuilds 改爲 true

典型用法

  1. 調用 inspect_text_file,檢查文件格式、條目數、說話人與標籤分佈。
  2. 調用 extract_text,提取可翻譯文本;可傳 output_jsonbatch_size 保存分塊 JSON。
  3. 由 DSH Agent 對批次執行翻譯,可藉助 subagentsubagent_forkworkflow 並行處理。
  4. 調用 assemble_text,將 translations_json 無損寫回 original_file 對應格式。

適用場景與注意

適合在 DSH 中處理遊戲腳本、字幕、PDF、Word、Markdown 等本地化文件的開發者。

注意:

  • 本插件只負責提取與裝配,不替代翻譯模型或翻譯策略。
  • 插件隨當前 dsh 進程權限運行;安裝前應檢查源碼、依賴和 MIT 許可證。
  • 可選依賴未安裝時,僅對應格式或獨立 LLM 流水線功能報錯,其餘功能不受影響。
  • 新 profile 初始化時,建議按上文檢查 @deepseek-ai/dsh-base 版本與 pnpm build scripts 設置。

結尾

dsh-plugin-text-translation 的價值在於把本地化流程裏最容易出錯的“標籤保護、切片、回填”從模型任務中拆出來,讓 DSH Agent 可以穩定地處理遊戲腳本和長文檔。

GitHub 倉庫:

https://github.com/1738348785/dsh-plugin-text-translation

插件目錄頁線索:

https://www.skillhub.cn/plugins/1738348785/dsh-plugin-text-translation

該目錄頁 URL 來自插件線索,未作爲已覈實事實展開。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜