https://github.com/yxw007/vscode-translate-next
🎉一款简单易用支持多种翻译引擎的vscode插件,A translate vscode extension that supports multiple translation engines
https://github.com/yxw007/vscode-translate-next
ai amazon azure baidu deepl google i18n translate translator vscode-extension
Last synced: 21 days ago
JSON representation
🎉一款简单易用支持多种翻译引擎的vscode插件,A translate vscode extension that supports multiple translation engines
- Host: GitHub
- URL: https://github.com/yxw007/vscode-translate-next
- Owner: yxw007
- License: mit
- Created: 2024-09-10T02:40:42.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2026-03-01T03:16:06.000Z (4 months ago)
- Last Synced: 2026-03-01T06:44:49.949Z (4 months ago)
- Topics: ai, amazon, azure, baidu, deepl, google, i18n, translate, translator, vscode-extension
- Language: CSS
- Homepage:
- Size: 15.3 MB
- Stars: 59
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# vscode-translate-next
English | [日語](README_ja.md) | [한국어](README_ko.md) | [简体中文](README_zh-CN.md)

Every programmer must have a vscode translation plugin artifact, it allows you to not be afraid of multi-language, but let you more focused immersive writing code! 🚀
> Note: Underlying translation support provided by [translate](https://github.com/yxw007/translate)
## 💖 Support me
If this tool helps you save time and improve work efficiency, please support me in the following ways to continue development and maintenance:
- Become my sponsor(GitHub Sponsors):https://github.com/sponsors/yxw007
- Give me a cup of coffee☕ (small reward) – every support can bring continuous improvement and more new features.

- Follow me Three-click videos (bilibili: [向往自由的码](https://space.bilibili.com/3546754775517426?spm_id_from=333.788.0.0))
- Clicking a Star⭐ on GitHub and recommending plugins to developers around you are all great encouragement.
I am very grateful for every support ❤️, which will be given priority for feature iteration and testing. If you have any special suggestions or wish I made a feature, please contact me via Issue or a private message.
## ✨ Features
- Simple and easy to use
- Support for multiple translation engines: Google, Azure, Amazon, Baidu, Deepl, etc
- Support for translation from one language to any language
- Support hover translate
- Replace selected text translation
- Supports translation of selected text in terminals
## 📋 Requirements
- vscode >= 1.91.0
## ⚙️ Config

Tips: In addition to the Google Translate engine, if you set other translation engines as the default translation engine, you need to configure the corresponding translation engine configuration, if other translation engines do not use it, you can do without configuration
### Hover extensions (custom)
- `Translate-next.hover.extensions`
- Default: A preset list of common programming language file extensions (comma-separated). Default value: `js,jsx,ts,tsx,java,py,c,h,cpp,cc,cxx,hpp,hh,hxx,rs,go,cs,php,rb,swift,kt,kts,scala,dart,lua`.
- Usage: Comma-separated extension allowlist. Dot is optional, e.g. `ts,js,py` or `.ts,.js,.py`.
- Special: Set to `*` to enable hover translation for all files (not recommended; may consume tokens unnecessarily).
- Note: If the default list doesn't include what you need, just append extensions.
### Custom engine configuration
- `Translate-next.customEngines`
- Purpose: Configure one or more custom translation engines in settings.
- Language codes: For ISO 639 values such as `en`, `ja`, or `zh`, see [Wikipedia: List of ISO 639 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
- Note: If you need a regional tag such as `zh-CN`, use the base language code together with the region suffix.
Setup steps:
1. Open VS Code Settings and search for `Translate-next.customEngines`.
2. Add an object with `name`, `apiUrl`, `method`, and `toLanguages`.
3. If your API needs a request body, use `body`; if it needs query params, use `query`; if it needs headers, use `headers`.
4. You can use `{{from}}`, `{{to}}`, and `{{text}}` placeholders in `headers`, `query`, and `body`.
5. If the translated text is nested in the JSON response, set `responsePath`, for example `response`, `data.translation`, or `choices[0].message.content`.
6. After saving the config, switch `defaultEngine` to your custom engine name.
Common fields:
- `name`: Unique custom engine name.
- `apiUrl`: Request URL.
- `method`: `GET` or `POST`.
- `headers`: Request headers.
- `query`: URL query parameters.
- `body`: Request body.
- `responsePath`: Path used to read the translated text from the response JSON. Bracket syntax such as `choices[0].message.content` is supported.
- `fromLanguages`: Source language map. Key is the language name, value is the language code.
- `toLanguages`: Target language map. Key is the language name, value is the language code.
- `batchStrategy`: Multi-line request mode. Supports `none`, `join`, and `array`.
- `joinDelimiter`: Delimiter used when `batchStrategy=join`.
- `timeout`: Request timeout in milliseconds.
Example:
```json
"Translate-next.customEngines": [
{
"enabled": true,
"name": "my-ollama",
"apiUrl": "http://localhost:11434/api/generate",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": {
"model": "translategemma:4b",
"prompt": "Translate {{text}} from {{from}} to {{to}}",
"stream": false
},
"responsePath": "response",
"fromLanguages": {
"Chinese": "zh",
"English": "en",
"Japanese": "ja",
"Korean": "ko"
},
"toLanguages": {
"Chinese": "zh",
"English": "en",
"Japanese": "ja",
"Korean": "ko"
},
"timeout": 30000
}
]
```
Response example:
```json
{
"response": "Hello, world!"
}
```
For an API like this, set `responsePath` to `response`.
For a Chat Completions style API, you can also configure it like this:
```json
{
"name": "siliconflow-chat",
"apiUrl": "https://api.siliconflow.cn/v1/chat/completions",
"method": "POST",
"headers": {
"Authorization": "Bearer sk-xxxx",
"Content-Type": "application/json"
},
"body": {
"model": "Qwen/Qwen2.5-7B-Instruct",
"messages": [
{
"role": "user",
"content": "Translate the following text into English: {{text}}"
}
]
},
"responsePath": "choices[0].message.content",
"toLanguages": {
"English": "en"
}
}
```
## 💻Supported Translation Engines
| Name | Support | Description |
| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| google | ✔ | Commissioned and ready for use |
| azure translate | ✔ | Commissioned and ready for use |
| amazon translate | ✔ | Commissioned and ready for use |
| baidu | ✔ | Commissioned and ready for use |
| deepl | ✔ | Commissioned and ready for use |
| openai | ✔ | Commissioned and ready for use (Poor results, cue words are hard to tune in) |
| tencent | ✔ | Commissioned and ready for use |
| yandex | | I have not tuned in as I do not have a bank account supported by the platform (help from those who are in a position to do so is welcome and appreciated) |
## 🛠️ Usage
Download:[vscode-translate-next](https://marketplace.visualstudio.com/items?itemName=yxw007.vscode-translate-next)
- Select translated text

- Hover translation

- Translation terminal selected text

(Hint: If the shortcut key doesn't work, you can tap the Terminal Text Translation button at the bottom bar)

- How to use openai

### 📹 Video Tutorials
- [VSCode必备插件神器,让你更沉浸式写代码](https://www.bilibili.com/video/BV1Y1zMYQEbi/?vd_source=eaea9ad794278c4e15f13efa6d046736)
- [快速上手vscode翻译神器](https://www.bilibili.com/video/BV1eVzZYoEkf/?vd_source=eaea9ad794278c4e15f13efa6d046736)
### ⌨️ Shortcut key
| Description | Shortcut key |
| ------------------------------------------- | --------------------------------------------------------- |
| Replace Translate Selected Text | Shift + Alt + T |
| Switch the target language | Ctrl + Alt + Shit + L (Mac os: Command + Alt + Shift + L) |
| Switch the default translation engine | Alt + Shit + E |
| Viewing Plugin Output Logs | Ctrl + Alt + Shit + O (Mac os: Command + Alt + Shift + O) |
| Cleaning the plugin output log | Ctrl + Alt + C (Mac os: Command + Alt + C) |
| Translate the selected text in the terminal | Ctrl + Alt + ` (Mac os: Command + Alt + `) |
| Clean the terminal translation log | Alt + C |
| Open the terminal translation panel | Alt + Shift + O |
| Hover Translation: Enable/Disable | Ctrl + Alt + E |
Tip: If your editor environment has conflicting shortcuts, you can modify and adjust them yourself. If you forget the shortcut keys, you can use the status bar button provided in the bottom status bar to switch between the target language and the default translation engine, as shown in the following figure:

## ❓ FAQ
1. Report: fetch failed error popup

> A: If you have not switched the default engine then you are using Google, and at this time your computer can not access Google will report this error!
2. How do I get keys for other translation engines?
> A: Check the documentation [https://github.com/yxw007/translate](https://github.com/yxw007/translate) Engine Options Configuration Content
3. Baidu Translation Related, Common Errors
| error code | connotation | description |
| ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------- |
| 52003 | unauthorized user | Please check if the appid is correct or if the service is enabled! |
| 54003 | restricted access | The opened service may be a generic text translation service, which needs to be switched to a domain translation service. |
> For more error codes, see [Error Code List](https://api.fanyi.baidu.com/doc/22).
4. Pressing a shortcut doesn't work, how can I fix it?
- Possible situation 1: The shortcuts in vscode conflict, just modify the conflicting shortcuts
- Possible situation 2: The shortcut conflicts with the external software shortcut, gradually exit the external software, troubleshoot the conflicting software, and then modify the shortcut
- Hidden features:
- In the edit view, you can right click to replace the selected translation

- Select Text Translation on the terminal, and you can open it in the settings interface and display it in the bottom bar

5. If you avoid the consumption of large numbers of translated characters?
- Increase cache time

- Control which translation features you want to turn on and off

- Avoid selecting a large amount of text, then hover over the selected text. At this point, if hover translation is enabled, it will quickly consume a large number of translated characters, so you should avoid this operation
## 📢 More
- To configure other translation engines, you can read the documentation [translate README](https://github.com/yxw007/translate/blob/master/README_zh-CN.md)
- If you encounter problems and don't know how to solve them, you can leave me a message, add my wechat(aa4790139), or submit the Issue.
## 📄 License
vscode-translate-next is released under the MIT license. for more information, see the [LICENSE](./LICENSE) file.