dsh-translate-pin:DSH 划词与截图原位翻译(Windows)

Preface

When reading English documents or comparing foreign-language interfaces within DeepSeek Harness (DSH), users often copy text to translation tools or open another window to compare screenshots. Separating the translation from the original text makes it difficult for screenshot translation to preserve layout and citation styles. dsh-translate-pin is a community plugin designed for DSH users on Windows: select words in a session to generate a translation card; select an area on the desktop for DeepSeek to read and translate images, then fill the Chinese translation back into the original area; selection results can also be pinned to the desktop for pinned comparison. The following sections explain installation, usage, and important considerations.

What is this

  • Name: dsh-translate-pin (bundle id: translate-pin)
  • Maintainer: zhaopw5
  • Category: Internet Tools (Community Directory SkillHub Plugin Page)
  • Repository: github.com/zhaopw5/dsh-translate-pin, License MIT; package.json version 0.8.4
  • Platform: Windows only (OCR relies on Windows.Media.Ocr; badges and global hotkeys rely on Win32)

The plugin provides selection translation within DSH; it also launches a desktop assistant (pinwin.py) responsible for global selection, screenshot selection, in-place translation windows, and desktop badges. Translation prioritizes the DeepSeek configured in DSH (models supporting image input read images directly); if unavailable, it falls back to Bing/Google/MyMemory combined with Windows OCR.

Core Features

Selection Translation (DSH Pages)

Select foreign text in chat or article content (does not trigger in input boxes or contenteditable areas). After releasing the mouse, a “Translate” option appears next to the selection. Clicking it displays the source language, Simplified Chinese, translation, and service provider. The card supports copying, viewing the original, and pinning to the desktop. Purely Chinese selections are automatically skipped. Hotkey: Ctrl+Shift+T.

Global Selection (Browser, PDF, Word, etc.)

Drag to select text in any application outside DSH (drag movement > 6px). After releasing the mouse, a “Translate” option appears next to the cursor. You can also use Ctrl+Shift+T. The principle involves simulating Ctrl+C to read the clipboard and restoring it after reading; words cannot be selected in scenarios where Ctrl+C is not supported, such as certain terminals or games.

Screenshot Translation (Translation Filled Back to Original Area)

Enter selection mode via the “Screenshot Translation” in the bottom right, the desktop “Translate” badge, or the global Ctrl+Shift+S (works even when DSH is minimized). After confirming “✓ Translate”: OCR splits lines and segments based on line height/indentation/font size. DeepSeek translates the whole paragraph, then composes an image to place each Chinese paragraph back into its corresponding rectangle, attempting to preserve the citation box background color, left vertical line, and main text color. When stationary, the translation area has a gray gradient border; moving the mouse over it displays a toolbar with Pin, Copy, and View Original. Translation boxes support dragging, and double-clicking switches between translation and original text.

Table Mode

When selecting an entire table, it translates by cell, preserving table lines, column widths, and numbers, while only replacing text cells. It falls back to paragraph mode if complex merged cells or OCR side-by-side failures occur.

Ask AI (Screenshot Conversation)

After selection, click “✨ Ask AI” to open a separate window with screenshot preview and conversation. The question is sent to the DeepSeek configured in DSH, allowing follow-up questions. Screenshots are only sent to that model and not uploaded to other services (each question consumes image and text tokens).

Desktop Badge and Pinning

A permanent circular “Translate · Screenshot” badge appears on the right side of the screen; clicking it starts selection. “Pin to Desktop” on a selection card generates a persistent, draggable, and copyable comparison window.

Environment Requirements

Dependencies Description
Windows 10 / 11 OCR, topmost windows (tkinter)
DeepSeek Harness Desktop or dsh web (requires Connection / WebServer)
Python 3.10+ (tkinter, Pillow) Not required if running the DSH desktop built-in runtime
Windows PowerShell 5.1 System built-in
RapidOCR (optional) python -m pip install rapidocr_onnxruntime; falls back to Windows OCR if not installed
Chinese OCR language pack Windows Settings → Language → Chinese (Simplified) → “Optical Character Recognition” optional feature

When the plugin starts, it automatically looks for paths like $DSH_HOME/dsh-runtimes/*/dependencies/python/pythonw.exe, or you can specify the Python path using the environment variable DSH_TRANSLATE_PYTHON.

Installation and Enablement

In the DSH ecosystem, plugins are loaded via profiles and bundles; there is no official affiliation between the Community Directory SkillHub and DeepSeek/Huansuan. It is recommended to review the repository source code and the MIT license before installing. The plugin runs with the permissions of the current DSH process. It involves clipboard, screenshots, and online translation. Please assess whether your environment is suitable.

In the DSH “Plugins” page, select “Install from GitHub” and enter:

github:zhaopw5/dsh-translate-pin

Or execute in a profile allowed to manage dsh plugin:

dsh plugin --profile <profile> add github:zhaopw5/dsh-translate-pin

After installation, translate-pin will be automatically inserted into cordis.patch.yml. If dsh plugin is denied on the desktop version, use the in-app “Plugins” page to install.

Restart the Client After Installation

Plugin module lists are injected at startup; you must completely exit DeepSeek Harness and reopen it to verify:

  1. “Screenshot Translation” appears in the bottom right of any session;
  2. “Translate” appears next to the selection after selecting foreign text;
  3. No dsh-translate-pin errors in the console.

Configuration

After installing the bundle, override configuration in the profile patch by id (do not insert repeatedly):

- id: translate-pin
  config:
    targetLanguage: zh-Hans   # Default Simplified Chinese; can fill in en / ja / zh-Hant ...
Field Default Description
targetLanguage zh-Hans Target language code (shared by DeepSeek and Bing/Google fallback)

Pages that are already open need to be refreshed after modification; the host line can be reloaded with HMR.

Typical Usage Overview

Selection: Select foreign text in the page → Click “Translate” → Optionally “Pin to Desktop”.

Global Selection: Drag to select words in other apps → Click “Translate” or Ctrl+Shift+T.

Screenshot: Ctrl+Shift+S or badge → Drag to select → “✓ Translate” → View the filled-in translation in the original area; click “✨ Ask AI” when a conversation is needed.

Table: Select the entire table including lines, wait for cell-by-cell translation.

To troubleshoot, view the log: %USERPROFILE%\.dsh\translate-pin\host.log.

Applicable Scenarios and Limitations

Suitable for: Users who use DSH long-term on Windows and need to quickly localize foreign web pages/documents/screenshots, hoping the translation falls into the original position. When DeepSeek is configured and the model supports image reading, screenshot translation quality is more stable.

Notes:

  • Windows only; the desktop badge and hotkeys exit together when DSH is fully exited (child processes end with the host).
  • Style restoration is heuristic; when there are multiple colors/font sizes in one line, only the style with the largest proportion is taken.
  • Global selection and clipboard restrictions in some applications; if Ctrl+Shift+S is occupied, the log will show RegisterHotKey ... failed, you can switch to using the badge or page buttons.
  • OCR is mainly responsible for layout; body translation relies on DeepSeek reading the image, and accuracy will decrease if the model is unavailable.
  • Uninstall: Uninstall via the plugin page or dsh plugin --profile <profile> remove dsh-translate-pin, then restart the client; optionally delete the %USERPROFILE%\.dsh\translate-pin log directory.

Conclusion

dsh-translate-pin connects DSH session selection, system-level selection, and “Selection → DeepSeek Image Reading → In-place Filling” into a single pipeline, and supports desktop pinning for comparison. For installation details, refer to the repository README:

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

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

Xiaoye