An AI-powered Chrome browser translation extension that supports selection translation and full-page translation, making web translation smarter and more natural.
- Math Formula Preservation: Automatically detects and preserves MathJax/KaTeX formulas without translation
- Code Block Protection: Code snippets remain untouched during translation
- Elegant Menu Translation: Sidebar translations align perfectly with original text (not icons)
- Custom Prompts: Customize translation style with your own prompts (formal, casual, technical, etc.)
- Shows a translate button when text is selected
- Click the button to translate (popup or inline based on settings)
- Copy translation with one click
- Translations stay visible until explicitly cleared
- Hover a paragraph and press the hotkey (default: Shift) to translate inline
- Translation appears directly below the paragraph as bilingual text
- Press the hotkey again to restore the original view
- Hotkey is configurable in Settings
- Press
Escto clear inline translations, or right-click a paragraph/translation to cancel it
- Translate the entire webpage with one click
- Translations appear below original text, preserving layout
- Inherits original styling (font, color, size)
- Toggle show/hide translations
- High-performance batch translation (100 items/batch, 8 concurrent)
- Inline translations inherit original typography for a clean, consistent look
- Inline loading indicator is more visible to show translation progress
- Settings controls aligned for consistent spacing and visual hierarchy
- Draggable quick action button
- Supports translating selection, page, and toggling translations
- Position auto-saves, persists across page navigation
- Right-click context menu translation
- Dark/Light theme toggle
- Multi-language support (10+ languages)
- Input text translation dialog
git clone https://github.com/wangqianqianjun/translator.git
cd translator- Open Chrome browser
- Navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked"
- Select the
translatorfolder
- Click the extension icon in the browser toolbar
- Click "Settings"
- Fill in API configuration:
- API Endpoint: e.g.,
https://api.openai.com/v1/chat/completions - API Key: Your API key
- Model Name: e.g.,
gpt-4o-mini
- API Endpoint: e.g.,
- Select target translation language
- Click "Save Settings"
- Select text on any webpage
- Click the "Translate" button that appears
- View translation in popup or inline (based on settings), click to copy
- Press
Escor click × to close/clear
- Move the mouse over a paragraph
- Press the hover hotkey (default:
Shift) - Translation appears below the paragraph
- Press the hotkey again to restore the original view
- Press
Escto clear inline translations, or right-click a paragraph/translation to cancel it
Method 1: Float Ball
- Click the float ball in the bottom-right corner
- Select "Translate Page"
Method 2: Extension Menu
- Click the extension icon in toolbar
- Click "Translate Page"
Method 3: Context Menu
- Right-click on the page
- Select "Translate this page"
After translation:
- Click the float ball
- Select "Hide Translations" or "Show Translations"
- Translations are preserved, no need to re-translate
Works with any OpenAI-compatible API endpoint. Just configure the endpoint URL, API key, and model name.
| Service | Example API Endpoint | Notes |
|---|---|---|
| OpenAI | https://api.openai.com/v1/chat/completions |
GPT-4o, GPT-4o-mini, etc. |
| Anthropic Claude | https://api.anthropic.com/v1/messages |
Claude Sonnet, Opus, Haiku |
| Azure OpenAI | https://your-resource.openai.azure.com/... |
|
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai/chat/completions |
Gemini Pro, Flash, etc. |
| DeepSeek | https://api.deepseek.com/v1/chat/completions |
DeepSeek-V3, etc. |
| OpenRouter | https://openrouter.ai/api/v1/chat/completions |
Multiple providers |
| Ollama (Local) | http://localhost:11434/v1/chat/completions |
Local models |
| LM Studio (Local) | http://localhost:1234/v1/chat/completions |
Local models |
Auto-detection: The extension automatically detects Anthropic Claude API (by domain or
/v1/messagespath) and uses the correct request/response format.
简体中文 • 繁体中文 • English • 日本語 • 한국어 • Français • Deutsch • Español • Português • Русский
translator/
├── manifest.json # Chrome extension configuration
├── background/ # Background script
├── content/ # Content script & styles
├── popup/ # Popup menu
├── options/ # Settings page
├── i18n/ # Internationalization
└── icons/ # Extension icons
The extension follows a content-first architecture: content scripts collect and batch text, background scripts handle API calls, and UI surfaces manage user settings.
- Content Script: scans DOM, filters code/table/math, batches text with token estimation, inserts translations.
- Background Worker: builds prompts, calls OpenAI-compatible or Claude APIs, parses errors.
- Options/Popup UI: manages API key, model, prompt, theme, and quick actions.
- Storage: settings persisted in
chrome.storage.sync.
flowchart LR
U[User Action] --> C[Content Script]
C --> D[DOM Scan + Filters]
D --> P[Priority Split]
P --> B[Token-Aware Batching]
B -->|TRANSLATE / TRANSLATE_BATCH_FAST| W[Background Worker]
W -->|Prompt Build + Placeholder Rules| A[LLM API]
A --> W --> R[Translations]
R --> C --> I[Insert Translations into DOM]
S[Options/Popup] --> K[chrome.storage.sync]
K --> C
K --> W
MIT License
一款基于 AI 的 Chrome 浏览器翻译插件,支持划词翻译和全文翻译,让网页翻译更智能、更自然。
- 数学公式保留:自动识别并保留 MathJax/KaTeX 数学公式,不会被翻译破坏
- 代码块保护:代码片段在翻译过程中保持原样不变
- 优雅的菜单翻译:侧边栏译文与原文精确对齐(而非与图标对齐)
- 自定义 Prompt:支持自定义翻译风格(正式、口语化、技术文档等)
- 选中文本后显示翻译按钮
- 点击按钮进行翻译(弹窗或段落内显示,可在设置中切换)
- 支持复制译文
- 译文会保留,需手动清除
- 鼠标悬停段落并按下快捷键(默认:Shift)触发翻译
- 译文显示在段落下方,呈双语形式
- 再次按快捷键可恢复原文
- 快捷键可在设置中自定义
- 按
Esc清除所有段落译文,或右键段落/译文选择取消
- 一键翻译整个网页
- 译文显示在原文下方,保持原网页布局
- 继承原文样式(字体、颜色、大小)
- 支持显示/隐藏译文切换
- 高性能批量翻译(100条/批,8并发)
- 译文继承原始排版,整体视觉更统一
- 内嵌加载提示更清晰,便于感知翻译进度
- 设置页控件对齐,层级更清晰
- 可拖动的快捷操作球
- 支持翻译选中文本、翻译页面、显示/隐藏译文
- 位置自动保存,跨页面保持
- 右键菜单快速翻译
- 深色/浅色主题切换
- 支持多种目标语言(10+语言)
- 输入文本翻译对话框
git clone https://github.com/wangqianqianjun/translator.git
cd translator- 打开 Chrome 浏览器
- 地址栏输入
chrome://extensions/ - 开启右上角「开发者模式」
- 点击「加载已解压的扩展程序」
- 选择
translator文件夹
- 点击浏览器工具栏中的插件图标
- 点击「打开设置」
- 填写 API 配置:
- API 地址: 如
https://api.openai.com/v1/chat/completions - API Key: 你的 API 密钥
- 模型名称: 如
gpt-4o-mini
- API 地址: 如
- 选择目标翻译语言
- 点击「保存设置」
- 在网页中选中需要翻译的文字
- 点击出现的「翻译」按钮
- 在弹窗或段落内查看译文(取决于设置),可点击复制
- 按
Esc或点击 × 关闭/清除
- 将鼠标移动到段落上
- 按下悬停快捷键(默认:
Shift) - 译文显示在段落下方
- 再次按快捷键恢复原文
- 按
Esc清除所有段落译文,或右键段落/译文选择取消
方式一:悬浮球
- 点击页面右下角的悬浮球
- 选择「翻译整个页面」
方式二:插件菜单
- 点击浏览器工具栏的插件图标
- 点击「翻译当前页面」
方式三:右键菜单
- 在页面空白处右键
- 选择「翻译整个页面」
翻译完成后:
- 点击悬浮球
- 选择「隐藏译文」或「显示译文」
- 译文会被保留,再次显示无需重新翻译
支持所有 OpenAI 兼容的 API 接口,只需配置接口地址、API Key 和模型名称即可。
| 服务 | API 地址示例 | 说明 |
|---|---|---|
| OpenAI | https://api.openai.com/v1/chat/completions |
GPT-4o, GPT-4o-mini 等 |
| Anthropic Claude | https://api.anthropic.com/v1/messages |
Claude Sonnet, Opus, Haiku |
| Azure OpenAI | https://your-resource.openai.azure.com/... |
|
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai/chat/completions |
Gemini Pro, Flash 等 |
| DeepSeek | https://api.deepseek.com/v1/chat/completions |
DeepSeek-V3 等 |
| OpenRouter | https://openrouter.ai/api/v1/chat/completions |
多种模型提供商 |
| Ollama (本地) | http://localhost:11434/v1/chat/completions |
本地模型 |
| LM Studio (本地) | http://localhost:1234/v1/chat/completions |
本地模型 |
自动检测:插件会自动检测 Anthropic Claude API(通过域名或
/v1/messages路径),并使用正确的请求/响应格式。
简体中文 • 繁体中文 • English • 日本語 • 한국어 • Français • Deutsch • Español • Português • Русский
translator/
├── manifest.json # Chrome 扩展配置
├── background/ # 后台脚本
├── content/ # 内容脚本 & 样式
├── popup/ # 弹出菜单
├── options/ # 设置页面
├── i18n/ # 国际化
└── icons/ # 插件图标
插件采用内容脚本驱动的架构:内容脚本负责收集与分批,后台负责调用 API,UI 管理用户配置。
- Content Script:扫描 DOM,过滤代码/表格/公式,基于 token 估算分批并插入译文。
- Background Worker:构建 Prompt,调用 OpenAI 兼容或 Claude API,统一错误处理。
- Options/Popup UI:管理 API Key、模型、Prompt、主题与快捷操作。
- Storage:配置持久化在
chrome.storage.sync。
flowchart LR
U[用户触发] --> C[Content Script]
C --> D[DOM 扫描与过滤]
D --> P[首屏优先分组]
P --> B[Token 估算分批]
B -->|TRANSLATE / TRANSLATE_BATCH_FAST| W[Background Worker]
W -->|构建 Prompt + 占位符规则| A[LLM API]
A --> W --> R[译文结果]
R --> C --> I[插入译文到页面]
S[Options/Popup] --> K[chrome.storage.sync]
K --> C
K --> W
MIT License
Made with ❤️