Translate-selected
English | 中文
English
Translate selected text inline in VS Code. Supports Google Translate, DeepL, and Youdao (有道) translation providers.
✨ Features
- Inline Translation — Translation appears as a floating overlay above the selected text, without modifying the original content
- Multi-line Support — Select multiple lines and get line-by-line translation with uniform rectangular background
- Right-click Context Menu — Select text → right-click → "Translate Selected"
- Keyboard Shortcut — Quick translation with a single keystroke
- Input Translation — Translate any text via an input box (no selection needed)
- Multiple Providers — Switch between Google, DeepL, and Youdao freely
- 36 Languages — Searchable dropdown for source/target language selection
- Auto-dismiss — Translation overlay automatically clears after 8 seconds, or when you type/move cursor
📦 Installation
Search for Translate-selected in the VS Code Extensions Marketplace and click Install.
🚀 Usage
Translate Selected Text
- Select text in the editor
- Use one of the following methods:
- Keyboard shortcut:
Ctrl+Shift+T (Windows/Linux) or Cmd+4 (macOS)
- Right-click → select "Translate Selected"
- Command Palette (
Ctrl+Shift+P / Cmd+Shift+P) → type "Translate Selected"
- The translation appears as a floating overlay above the selected text

Translate Input Text
- Open Command Palette (
Ctrl+Shift+P / Cmd+Shift+P)
- Type "Translate Input"
- Enter the text you want to translate in the input box
- The translation appears inline at the cursor position
≤
⌨️ Keyboard Shortcuts
| Shortcut |
Platform |
Command |
Ctrl+Shift+T |
Windows / Linux |
Translate Selected |
Cmd+4 |
macOS |
Translate Selected |
⚙️ Configuration
Open Settings (Ctrl+, / Cmd+,) and search for translate-selected.
General
| Setting |
Default |
Description |
translate-selected.provider |
google |
Translation provider: google, deepl, or youdao |
translate-selected.sourceLanguage |
auto |
Source language (searchable dropdown, supports 36 languages) |
translate-selected.targetLanguage |
zh-CN |
Target language (searchable dropdown, supports 36 languages) |
| Setting |
Default |
Description |
translate-selected.google.apiKey |
"" |
Google Cloud Translation API key (Get one here) |
| Setting |
Default |
Description |
translate-selected.deepl.apiKey |
"" |
DeepL API authentication key (Get one here) |
translate-selected.deepl.apiUrl |
https://api-free.deepl.com/v2/translate |
API endpoint. Use https://api.deepl.com/v2/translate for DeepL Pro |
| Setting |
Default |
Description |
translate-selected.youdao.appKey |
"" |
Youdao application key (Apply here) |
translate-selected.youdao.appSecret |
"" |
Youdao application secret |
🌍 Supported Languages
Chinese (Simplified), Chinese (Traditional), English, Japanese, Korean, French, German, Spanish, Portuguese, Portuguese (Brazil), Russian, Italian, Dutch, Polish, Arabic, Thai, Vietnamese, Indonesian, Malay, Turkish, Ukrainian, Czech, Danish, Finnish, Greek, Hungarian, Swedish, Norwegian, Romanian, Slovak, Bulgarian, Estonian, Latvian, Lithuanian, Slovenian, Croatian
📝 Provider Notes
| Provider |
Website |
Notes |
| Google |
cloud.google.com |
Requires a Google Cloud Translation API key. Supports auto source detection. |
| DeepL |
deepl.com |
Free tier uses api-free.deepl.com. Language codes are automatically mapped (e.g. zh-CN → ZH-HANS). |
| Youdao |
ai.youdao.com |
Uses v3 signature. Language codes are automatically mapped (e.g. zh-CN → zh-CHS). |
中文
在 VS Code 中内联翻译选中的文本。支持 Google 翻译、DeepL 和 有道翻译 三大翻译服务。
✨ 功能特性
- 内联翻译 — 翻译结果以浮动覆盖层显示在选中文本上方,不会修改原始内容
- 多行支持 — 选中多行文本,逐行翻译,背景统一为整齐的矩形
- 右键菜单 — 选中文本 → 右键 → "Translate Selected"
- 快捷键 — 一键快速翻译
- 输入翻译 — 通过输入框翻译任意文本(无需选中)
- 多引擎切换 — 自由切换 Google、DeepL、有道
- 36 种语言 — 可搜索的下拉菜单选择源语言/目标语言
- 自动消失 — 翻译结果 8 秒后自动清除,或在输入/移动光标时立即清除
📦 安装
在 VS Code 扩展市场中搜索 Translate-selected,点击 安装 即可。
🚀 使用方法
翻译选中文本
- 在编辑器中选中文本
- 使用以下任一方式:
- 快捷键:
Ctrl+Shift+T(Windows/Linux)或 Cmd+4(macOS)
- 右键 → 选择 "Translate Selected"
- 命令面板(
Ctrl+Shift+P / Cmd+Shift+P)→ 输入 "Translate Selected"
- 翻译结果将以浮动覆盖层显示在选中文本上方

翻译输入文本
- 打开 命令面板(
Ctrl+Shift+P / Cmd+Shift+P)
- 输入 "Translate Input"
- 在输入框中输入要翻译的文本
- 翻译结果将显示在光标位置
⌨️ 快捷键
| 快捷键 |
平台 |
命令 |
Ctrl+Shift+T |
Windows / Linux |
翻译选中文本 |
Cmd+4 |
macOS |
翻译选中文本 |
⚙️ 配置说明
打开 设置(Ctrl+, / Cmd+,),搜索 translate-selected。
通用设置
| 设置项 |
默认值 |
说明 |
translate-selected.provider |
google |
翻译引擎:google、deepl 或 youdao |
translate-selected.sourceLanguage |
auto |
源语言(可搜索下拉菜单,支持 36 种语言) |
translate-selected.targetLanguage |
zh-CN |
目标语言(可搜索下拉菜单,支持 36 种语言) |
| 设置项 |
默认值 |
说明 |
translate-selected.google.apiKey |
"" |
Google Cloud Translation API 密钥(获取密钥) |
| 设置项 |
默认值 |
说明 |
translate-selected.deepl.apiKey |
"" |
DeepL API 认证密钥(获取密钥) |
translate-selected.deepl.apiUrl |
https://api-free.deepl.com/v2/translate |
API 端点。DeepL Pro 用户请使用 https://api.deepl.com/v2/translate |
| 设置项 |
默认值 |
说明 |
translate-selected.youdao.appKey |
"" |
有道应用 ID(申请地址) |
translate-selected.youdao.appSecret |
"" |
有道应用密钥 |
🌍 支持的语言
简体中文、繁体中文、英语、日语、韩语、法语、德语、西班牙语、葡萄牙语、巴西葡萄牙语、俄语、意大利语、荷兰语、波兰语、阿拉伯语、泰语、越南语、印尼语、马来语、土耳其语、乌克兰语、捷克语、丹麦语、芬兰语、希腊语、匈牙利语、瑞典语、挪威语、罗马尼亚语、斯洛伐克语、保加利亚语、爱沙尼亚语、拉脱维亚语、立陶宛语、斯洛文尼亚语、克罗地亚语
📝 翻译引擎说明
| 引擎 |
官网 |
说明 |
| Google |
cloud.google.com |
需要 Google Cloud Translation API 密钥,支持 auto 自动检测源语言 |
| DeepL |
deepl.com |
免费版使用 api-free.deepl.com,语言代码自动映射(如 zh-CN → ZH-HANS) |
| 有道 |
ai.youdao.com |
使用 v3 签名,语言代码自动映射(如 zh-CN → zh-CHS) |
如果你看到错误提示 DeepL API key is not configured,请按下面任一方式添加你的 DeepL API Key:
通过 settings.json 添加(适合希望直接编辑配置的用户):
- 打开命令面板(
Cmd+Shift+P),输入 Preferences: Open Settings (JSON) 并回车,或者在设置界面(Cmd+,)中点击右上角的打开 JSON 图标。
- 在打开的
settings.json 中加入(替换为你的实际 API Key):
"translate-selected.provider": "deepl",
"translate-selected.deepl.apiKey": "YOUR_DEEPL_API_KEY"
通过设置 UI 添加(适合不想编辑 JSON 的用户):
- 打开设置(
Cmd+,),在搜索框输入 Translate-selected。
- 找到
DeepL: Api Key(或 translate-selected.deepl.apiKey),将你的 API Key 粘贴到对应输入框并保存。
完成配置后,保存设置并重载 VS Code 窗口(Cmd+Shift+P → 输入 Developer: Reload Window),然后重试翻译命令。
提示:如果你使用 DeepL Pro,请同时将 translate-selected.deepl.apiUrl 改为 https://api.deepl.com/v2/translate。
�️ Development / 开发指南
Prerequisites / 前置要求
Setup / 环境搭建
# Clone the repository / 克隆仓库
git clone https://github.com/cliff/vscode-translation-cc.git
cd vscode-translation-cc
# Install dependencies / 安装依赖
npm install
Scripts / 脚本说明
| Command / 命令 |
Description / 说明 |
npm run dev |
Start development mode with watch (开发模式,自动监听文件变化) |
npm run compile |
Build production bundle (构建生产版本) |
Development Workflow / 开发流程
Start dev mode / 启动开发模式
npm run dev
This watches for file changes and rebuilds automatically.
自动监听文件变化并重新构建。
Debug in VS Code / 在 VS Code 中调试
- Press
F5 to launch Extension Development Host
- 按
F5 启动扩展开发宿主
Build for production / 构建生产版本
npm run compile
Publishing / 发布
# Update version / 更新版本号
npm version patch # or minor / major
# Package vsix / 打包 vsix
npx vsce package
# Publish to marketplace / 发布到市场
npx vsce publish
�📄 License
MIT
🙏 Acknowledgement