dsh-page-translator:整页主题感知翻译与中文→英文社区回复

Preface

When looking up information in DSH or browsing English communities, a common practice is to open a translation plugin for sentence-by-sentence machine translation, or to copy the main text to the sidebar and pass it to a model. The former often ignores the page topic, so Film and Develop in film communities are translated literally; the latter interrupts the reading flow, and writing Reddit comments requires manually changing the Chinese to English. Below is an introduction to dsh-page-translator, maintained by SenhoiBot: it performs in-place translation replacement on real pages, preserves layout, and reuses the DSH host model for topic terminology and Chinese drafts to English replies, without requiring a separate API key.

What is this

dsh-page-translator is a network-enabled plugin for DeepSeek Harness (current package version 0.7.0, MIT license). The same page controller supports two entry points:

  • DSH Desktop built-in browser (right side, Electron <webview>): The “Translate” capsule in the bottom right corner of the page;
  • Edge / Chrome MV3 unpacked extension (inside repository edge-extension/): Same control on any http/https page; translation is completed via the local DSH extension bridge.

The built-in browser in Web DSH is a cross-origin iframe, so the plugin cannot read the DOM; the built-in browser mode only works on the desktop installation version. Both the plugin and extension call via ctx.llm (inference strength off), with quotas and credentials borne by the running DSH process.

Core Features

Full-page Thematic Translation

Translation combines the full page theme, not isolated machine translation sentence by sentence. The README gives an example: on film photography sites, Film → Film/Reel, Develop → Development, Magazine (16mm) → Magazine cassette. Process-wise, first perform a theme and glossary analysis on the page (host route POST /page-translator/context), then translate in chunks in parallel and write back to the DOM in place; no proxy is used, so login state, scripts, and layout are preserved.

Progress is displayed as a percentage (e.g., “Translating 42%”, “Translated 100%”), no longer showing paragraph summaries. New DOM from Reddit pagination, infinite scrolling, expanding comments, etc., will automatically continue translating (briefly “Updating …%”), no need to manually restore and click again.

Chinese → English Reply (Community Interaction)

To the right of the “Translate” button is an input box and a tone dropdown (Natural / Colloquial / Humorous / Professional, default Natural). After typing Chinese and pressing Enter or clicking →EN, an English reply is generated based on the current page topic and tone, displayed in a floating layer and ready to copy, targeting Reddit and other English community comments. The prompt includes built-in translation rules for common Chinese internet slang (e.g., 真香, 入坑, 刀锐奶化), requiring it to be short, colloquial, and sound like a native comment rather than a literal translation.

Switching the tone for the same Chinese sentence regenerates the result (the README has an example table showing the English differences for “Grateful Lens” under different tones).

Floating Controls and Position Memory

The entire “Translate” capsule can be dragged (hold the icon/text area; dragging is not triggered on the input box, dropdown, or →EN). The position is remembered across pages in both the built-in browser and the Edge extension; the drag threshold is 5px, and the end of a drag swallows accidental clicks. The reply floating layer is anchored above/below the controls.

Edge Extension and Local Bridge

The extension itself does not call the model: the content script accesses http://127.0.0.1:34118/ext/* via the service worker (shared with the host LlmTranslator and LRU cache). The bridge listens on the loopback address by default; optionally, configure extensionToken to match the token in the extension options to strengthen access control.

Installation and Activation

dsh plugin --profile <profile> add github:SenhoiBot/dsh-page-translator

You can also use link: to install when you have the source code directory locally (see repo README). After installation, refresh the DSH interface; modifying index.js / lib/* requires restarting the DSH instance, while modifying client.js / page-script-hosted.js only requires refreshing and reloading the built-in browser page.

Edge Extension (Optional)

  1. Ensure DSH Desktop is running (the extension relies on the host bridge; when closed, the button will prompt connection failure).
  2. Open edge://extensions, enable Developer Mode, click “Load unpacked” → select the edge-extension inside the plugin directory (typical path looks like ...\plugins\dsh-page-translator\edge-extension).
  3. In the extension options, the bridge address defaults to http://127.0.0.1:34118; you can “Test Connection” (when successful, the README states it displays Connection Successful: DSH Extension Bridge v0.3.0).
  4. Open a normal webpage and click the “Translate” in the bottom right to verify translation and restoration.

Pages inside edge://, chrome://, the extension store, and PDF readers cannot be injected.

Typical Usage

  1. In the DSH built-in browser on the right, or a page with the extension loaded in Edge, open the target URL.
  2. Click the “Translate” in the bottom right to start full-page translation; click again to restore the original text. After scrolling or pagination, new content will automatically follow up with translation.
  3. To reply in the community: write Chinese in the input box, select the tone, press Enter or →EN → copy the floating English layer → paste into the site’s comment box.

Film community and Reddit-like scenarios have reproducible examples in the “Internet Sense” comparison table and E2E scripts (e.g., e2e/compose-live.mjs) in the README.

Configuration

Override by plugin id in the profile patch (all optional):

- id: dsh-page-translator
  config:
    provider: deepseek-account   # Default uses DSH default model
    model: deepseek-flash
    target: zh                   # zh/en/ja/ko/ru
    port: 34118                  # Edge extension bridge loopback port (0 = random)
    extensionToken: ''           # Optional, matches extension options
    callTimeoutMs: 25000
    llmConcurrency: 8

If 34118 is occupied, the plugin will fall back to a random port: the built-in browser remains usable, but the extension needs to change the bridge address or specify an idle port.

Suitable Scenarios and Notes

Who is it for: Users who frequently read foreign language sites in the DSH built-in browser or Edge, and draft replies in Chinese in English communities before needing authentic English replies; DSH desktop users who need to preserve page interaction and login state but do not want to configure another set of API keys in the plugin.

Security and Permissions: The plugin runs with the permissions of the current DSH process, and model calls use the host configuration; it is recommended to read the GitHub repository source code and MIT license before installing. The extension communicates only via the local loopback bridge and does not add extra network requests to target sites (dragging and position use the existing injection bridge or chrome.storage.local).

Performance Expectations: The README records that the cold start for page theme analysis is about 2.9s per page and about 10ms after caching; translation cache is in the host process LRU, so re-translation on the same page is almost instantaneous. Inference is fixed to off, and latency mainly comes from round-trip and chunked translation.

Conclusion

dsh-page-translator brings “reading foreign pages” and “replying in English” together into a single thematic translation and reply process, with the optional Edge extension covering browser tabs outside DSH. See the directory and instructions on the SkillHub Plugin Page, and source code and installation details on GitHub: SenhoiBot/dsh-page-translator.

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

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

Xiaoye