A powerful Chrome extension for real-time webpage translation using multiple LLM providers
WebTranslator is a Chrome browser extension that provides seamless webpage translation powered by advanced Large Language Models (LLM). It supports multiple Chinese and international LLM providers including Azure OpenAI, Doubao, Qwen, Kimi, and GLM, with full internationalization support and intelligent bilingual display.
- ✅ Multi-Provider Support: Added support for 4 major Chinese LLM providers
- ✅ Complete Internationalization: UI now available in 5 languages
- ✅ Manual Model Input: Flexible model configuration for future compatibility
- ✅ Native-Quality Translation: Optimized prompts for natural translations
- ✅ Smart Content Detection: Improved accuracy in identifying translatable content
- ✅ Chrome Web Store Ready: Fully compliant with Chrome Web Store requirements
- 🌐 Real-time Translation: Translate entire webpages while preserving layout and formatting
- 🤖 Multiple LLM Providers: Support for Azure OpenAI, Doubao (豆包), Qwen (千问), Kimi, GLM (智谱AI)
- 🌍 Multi-language Support: Interface available in English, Chinese, Spanish, Japanese, and Korean
- 📱 Bilingual Display: Shows original and translated content side-by-side with intelligent formatting
- 🎯 Smart Content Detection: Automatically identifies and translates meaningful content while avoiding code blocks and navigation elements
- ⚡ Progressive Translation: Renders translations in batches for responsive user experience
- 🔄 Restore Functionality: Easily switch back to original content with one click
- 🛠️ Flexible Configuration: Manual model input for maximum compatibility with new models
- 🎨 Modern UI: Clean, intuitive interface with gradient design and localized text
- 🔧 Native Speaker Quality: Optimized prompts for natural, native-like translations
The extension features a clean, modern popup interface with gradient styling that makes translation quick and intuitive.
Simple and elegant popup interface for quick translation
Comprehensive configuration options allow you to set up various LLM providers with detailed parameters.
Comprehensive configuration options for LLM providers including Azure OpenAI
The extension provides bilingual display showing both original and translated content seamlessly integrated into the webpage.
Bilingual display showing original English content with Chinese translations below each paragraph
- Visit the Chrome Web Store page
- Click "Add to Chrome"
- Grant necessary permissions
-
Clone this repository:
git clone https://github.com/bytedance/WebTranslator.git cd WebTranslator
-
Install dependencies:
npm install
-
Build the extension:
npm run build
-
Load in Chrome:
- Open
chrome://extensions/
- Enable "Developer mode"
- Click "Load unpacked"
- Select the project directory
- Open
- Click the extension icon and select "Settings"
- Choose your preferred provider from the dropdown:
- Azure OpenAI: Enterprise-grade OpenAI service
- Doubao (豆包): ByteDance's LLM service
- Qwen (千问): Alibaba Cloud's LLM service
- Kimi: Moonshot AI's LLM service
- GLM (智谱AI): Zhipu AI's LLM service
Each provider requires specific configuration:
Common Fields:
- Endpoint URL: Provider's API endpoint
- API Key: Your authentication key
- Model: Model name (manually entered for flexibility)
- Max Tokens: Response length limit (1000-8000 recommended)
- Temperature: Translation creativity (0.3 recommended for accuracy)
Example - Azure OpenAI:
- Endpoint:
https://your-resource.openai.azure.com
- API Version:
2024-03-01-preview
- Model:
gpt-4
orgpt-5-chat-2025-08-07
- Custom Headers:
{"X-TT-LOGID": ""}
(optional)
- Source Language: Auto-detect or specify (English, Chinese, etc.)
- Target Language: Choose your preferred translation language
-
Quick Translation:
- Navigate to any webpage
- Click the WebTranslator icon
- Select source and target languages
- Click "Translate Page"
-
View Results:
- Original content remains visible
- Translations appear below or inline with original text
- Headings show translations in parentheses
- Sidebar navigation maintains inline format
-
Restore Original:
- Click "Restore Original" to revert all translations
- Original formatting and content are preserved
WebTranslator/
├── manifest.json # Extension manifest (MV3) with i18n
├── src/
│ ├── background/ # Service worker
│ │ ├── service-worker.js
│ │ └── llm-providers/ # Multiple LLM provider implementations
│ │ ├── base-provider.js # Base provider class
│ │ ├── azure-openai.js # Azure OpenAI
│ │ ├── doubao.js # Doubao (豆包)
│ │ ├── qwen.js # Qwen (千问)
│ │ ├── kimi.js # Kimi (Moonshot AI)
│ │ └── glm.js # GLM (智谱AI)
│ ├── content/ # Content scripts
│ │ ├── translator.js # Main translation logic
│ │ └── styles.css # Translation styling
│ ├── popup/ # Extension popup
│ │ ├── popup.html # Localized popup interface
│ │ ├── popup.js # Popup logic with i18n
│ │ └── popup.css # Modern gradient styling
│ ├── options/ # Settings page
│ │ ├── options.html # Dynamic multi-provider config
│ │ ├── options.js # Provider management
│ │ └── options.css # Settings page styling
│ └── utils/ # Shared utilities
│ └── i18n.js # Internationalization helper
├── _locales/ # Internationalization
│ ├── en/ # English locale
│ ├── zh_CN/ # Chinese Simplified
│ ├── es/ # Spanish
│ ├── ja/ # Japanese
│ └── ko/ # Korean
├── icons/ # Extension icons
└── docs/ # Documentation
- Node.js 18+
- Chrome 120+
- npm or pnpm
npm install # Install dependencies
npm run dev # Development mode with hot reload
npm run build # Production build
npm run test # Run tests
npm run package # Package for distribution
- Extend
BaseProvider
class insrc/background/llm-providers/
- Implement required methods:
getName()
,translate()
,formatPrompt()
- Add provider to the registry in
service-worker.js
- Add provider schema to
PROVIDER_SCHEMAS
inoptions.js
- Update i18n files with provider name translations
All model names are manually entered rather than dropdown selections, allowing:
- Immediate support for newly released models
- Custom or experimental model usage
- No need to update the extension for new model versions
- Automatically excludes code blocks, navigation menus, and script content
- Prioritizes paragraph, heading, and list elements
- Preserves inline formatting and links
- Processes content in batches for responsive UI
- Shows loading indicators during translation
- Handles large pages efficiently
- Robust API error handling with user feedback
- Retry mechanisms for failed translations
- Graceful degradation for unsupported content
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
WebTranslator 是一个强大的 Chrome 浏览器扩展,使用先进的大语言模型(LLM)提供无缝的网页翻译服务。支持包括 Azure OpenAI、豆包、千问、Kimi、GLM 在内的多家中外LLM服务商,提供完整的国际化支持和智能双语显示功能。
- ✅ 多服务商支持: 新增支持4家主流中国LLM服务商
- ✅ 完整国际化: 界面现支持5种语言显示
- ✅ 手动模型输入: 灵活的模型配置,兼容未来版本
- ✅ 母语水准翻译: 优化提示词,输出自然流畅译文
- ✅ 智能内容识别: 提升可翻译内容识别准确性
- ✅ Chrome商店就绪: 完全符合Chrome网上应用店要求
- 🌐 实时翻译: 翻译整个网页同时保持布局和格式
- 🤖 多LLM提供商: 支持 Azure OpenAI、豆包、千问、Kimi、GLM 等多家服务商
- 🌍 多语言界面: 支持中文、英文、西班牙语、日语、韩语界面
- 📱 智能双语显示: 原文和译文并排显示,格式智能适配
- 🎯 智能内容识别: 自动识别并翻译有意义的内容,避免代码块和导航元素
- ⚡ 渐进式翻译: 分批渲染翻译以获得更好的用户体验
- 🔄 一键还原: 轻松切换回原始内容
- 🛠️ 灵活模型配置: 手动输入模型名称,兼容最新模型版本
- 🎨 现代UI: 简洁直观的渐变设计界面,完全本地化
- 🔧 母语品质: 优化翻译提示词,输出自然流畅的母语水平译文
扩展具有简洁现代的弹窗界面,渐变样式设计让翻译变得快速直观。
全面的配置选项允许您设置各种LLM提供商及详细参数。
扩展提供双语显示,将原文和译文无缝集成到网页中。
- 访问 Chrome网上应用店页面
- 点击"添加至Chrome"
- 授予必要权限
-
克隆此仓库:
git clone https://github.com/bytedance/WebTranslator.git cd WebTranslator
-
安装依赖:
npm install
-
构建扩展:
npm run build
-
在Chrome中加载:
- 打开
chrome://extensions/
- 启用"开发者模式"
- 点击"加载已解压的扩展程序"
- 选择项目目录
- 打开
- 点击扩展图标并选择"设置"
- 从下拉菜单选择您的首选服务商:
- Azure OpenAI: 企业级OpenAI服务
- 豆包: 字节跳动的大语言模型服务
- 千问: 阿里云的大语言模型服务
- Kimi: 月之暗面的大语言模型服务
- GLM: 智谱AI的大语言模型服务
每个服务商需要特定的配置:
通用字段:
- 端点URL: 服务商的API端点地址
- API密钥: 您的身份验证密钥
- 模型: 模型名称(手动输入以获得最大灵活性)
- 最大令牌: 响应长度限制(推荐1000-8000)
- 温度: 翻译创造性(推荐0.3以保证准确性)
示例 - Azure OpenAI:
- 端点:
https://your-resource.openai.azure.com
- API版本:
2024-03-01-preview
- 模型:
gpt-4
或gpt-5-chat-2025-08-07
- 自定义标头:
{"X-TT-LOGID": ""}
(可选)
- 源语言: 自动检测或指定(英语、中文等)
- 目标语言: 选择您偏好的翻译语言
-
快速翻译:
- 导航至任意网页
- 点击WebTranslator图标
- 选择源语言和目标语言
- 点击"翻译页面"
-
查看结果:
- 原始内容保持可见
- 翻译内容显示在原文下方或内联
- 标题翻译显示在括号中
- 侧边栏导航保持内联格式
-
还原原文:
- 点击"还原原文"撤销所有翻译
- 原始格式和内容得到保护
- Node.js 18+
- Chrome 120+
- npm 或 pnpm
npm install # 安装依赖
npm run dev # 开发模式
npm run build # 生产构建
npm run test # 运行测试
npm run package # 打包分发
- 自动排除代码块、导航菜单和脚本内容
- 优先处理段落、标题和列表元素
- 保持内联格式和链接
- 分批处理内容以保持响应性
- 显示翻译加载指示器
- 高效处理大型页面
欢迎贡献!请查看我们的贡献指南了解详情。
- Fork 仓库
- 创建功能分支
- 进行更改
- 添加测试(如适用)
- 提交拉取请求
本项目采用 Apache License 2.0 许可证 - 详见 LICENSE 文件。
Made with ❤️ by the WebTranslator Team
Transform language barriers into bridges for global communication