Skip to content

AgenticMatrix/WebTranslator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepSeek Web Page Translator

A Chrome extension that translates entire web pages using the DeepSeek-chat model. Offers fast concurrent translation, persistent caching, and instant switching between original and translated text.

Screenshots

Configuration Panel Original English Page Translated Chinese Page
Settings Original Translated

Features

  • Full-page translation — translate all visible text content on any web page
  • Concurrent requests — sends multiple API requests in parallel (configurable, default 6) for maximum speed
  • Batch merging — merges text segments into larger batches (default 100 segments or 10,000 chars per batch) to reduce API calls
  • Persistent cache — translations are cached in chrome.storage.session and survive page refreshes
  • Instant toggle — switch between original text and translation instantly with cached data (no re-translation needed)
  • Auto-restore — translated pages automatically show translation after refresh
  • Configurable — API key, target language, concurrency, merge size, and more
  • Convenient popup UI — one-click translate, language swap, and status feedback

Installation

From Source

  1. Open Chrome and go to chrome://extensions/
  2. Enable Developer mode (toggle in top-right corner)
  3. Click Load unpacked
  4. Select the deepseek-translator folder

Configuration

  1. Click the extension icon in the toolbar, then click the Settings button (⚙️)
  2. Enter your DeepSeek API Key from platform.deepseek.com
  3. (Optional) Adjust translation settings — concurrency, merge size, default target language
  4. Click Save or Test API Connection to verify

Usage

  1. Navigate to any web page
  2. Click the extension icon → choose source/target language → click Translate Page
  3. A progress bar appears at the top of the page during translation
  4. After translation completes, click the extension icon again to see toggle buttons:
    • 译文 (Translation) — switch to the translated content
    • 原文 (Original) — switch back to the original content
  5. Switching is instant — no re-translation needed

Tip: Translated pages automatically restore their translation after refresh — no need to re-translate.

Architecture

deepseek-translator/
├── manifest.json          # Chrome Extension Manifest V3
├── background.js          # Service Worker — API calls, concurrency control
├── content/
│   ├── content.js         # Text extraction, caching, DOM manipulation
│   └── content.css        # Progress banner styles
├── popup/
│   ├── popup.html         # Popup UI
│   ├── popup.js           # Popup logic — state sync, user interactions
│   └── popup.css          # Popup styles
├── options/
│   ├── options.html       # Settings page
│   ├── options.js         # Settings logic, API test
│   └── options.css        # Settings page styles
├── figs/                  # Screenshots
│   ├── config.png
│   ├── ori_page.png
│   └── translated_zh.png
└── icons/
    ├── icon16.png
    ├── icon48.png
    └── icon128.png

Data Flow

Popup clicks "Translate Page"
    │
    ▼
Content Script (content.js)
    ├── Extracts visible text nodes from DOM
    ├── Merges text into batches (configurable size/char limit)
    └── Sends all batches to Background Worker
           │
           ▼
Background Worker (background.js)
    ├── Concurrently translates each batch via DeepSeek API
    ├── Returns all results at once
    └── (Concurrency controlled by worker pool)
           │
           ▼
Content Script (content.js)
    ├── Splits batch results back to per-segment translations
    ├── Writes to dual cache: memory (instant) + chrome.storage.session (persist)
    └── Applies translations to DOM
           │
    ┌──────┴──────┐
    ▼              ▼
[Original]    [Translation]  ← instant toggle via memory cache
    │
    ▼
Page refresh → auto-restore from chrome.storage.session cache

Caching Strategy

Layer Storage Latency Purpose
Memory In-memory JS variable Zero Same-session toggle between original/translation
Session chrome.storage.session Async Persist across page refreshes

Each cached entry is keyed by trans:{origin}{pathname}:{targetLang}:{sourceLang}. Text nodes are identified by XPath + text-node index for reliable matching across DOM lifecycle.

Configuration

Setting Default Description
API Key Your DeepSeek API key (get from platform.deepseek.com)
API URL https://api.deepseek.com/v1/chat/completions API endpoint (change for proxy/mirror)
Model deepseek-chat DeepSeek model to use
Target Language Chinese Default target language
Concurrency 6 Max concurrent API requests (3–8 recommended)
Batch Merge Size 100 Max text segments per API request
Batch Max Chars 10,000 Max characters per API request (overrides merge size)

Requirements

  • Chrome browser (Manifest V3)
  • DeepSeek API key with active credits

Privacy

  • All translation requests go directly from your browser to DeepSeek's API
  • No third-party servers involved
  • Only visible text content on the page is sent for translation
  • Cached data is stored locally in chrome.storage.session (browser memory, cleared when browser closes)

License

MIT

About

A Chrome extension that translates entire web pages using the DeepSeek-chat model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors