Skip to content

Vscode Samge Translate 翻译助手:Quickly translate text right in your code 🚀 支持多种翻译命令(英译中、中译英、中文转多规则命名变量等),支持多种结果展示方式,支持配置百度、阿里、腾讯、火山、有道、DeepL翻译引擎。

License

Notifications You must be signed in to change notification settings

Samge0/vscode-samge-translate

Repository files navigation

VSCode Samge Translate Plugin

中文文档 | English | Github

VSCode Samge Translate is a translation plugin for VSCode that offers translation services from English to Chinese and vice versa. It also provides a feature for converting Chinese text into variable names, supporting multiple naming conventions such as camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, and snakeCase. This plugin leverages APIs from Baidu and other translation engines to deliver accurate translations.

The supported translation engines include: Baidu, Alibaba, Tencent, Volcano, Youdao, DeepL.

this gif displays the translation function interaction of this plugin the translation results can be displayed after the selected text in the OUTPUT panel in the bottom right corner prompt box or hovering over the text these display methods can be turned on or off in the configuration SamgeTranslateDisplay

Installation

You can install this plugin through the VSCode Extension Marketplace by searching for "VSCode Samge Translate".

Features

  • English to Chinese Translation: Translates selected English text into Chinese.
  • English to Chinese Translation - Auto Replace: Translates and automatically replaces selected English text with its Chinese translation.
  • Chinese to English Translation: Translates selected Chinese text into English.
  • Chinese to English Translation - Auto Replace: Translates and automatically replaces selected Chinese text with its English translation.
  • Chinese to Variable Name Conversion - Auto Replace: Automatically converts Chinese text into variable names in various programming naming formats.
  • Flexible Configuration: Customize translation engine parameters and more through VSCode settings.

Keyboard Shortcuts (Customizable)

Command Name Default Shortcut (Windows/Linux) Default Shortcut (macOS)
Samge Translate:英译中-en2zh alt+x alt+x
Samge Translate:英译中并替换-en2zhReplace ctrl+shift+alt+x ctrl+shift+alt+x
Samge Translate:中译英-zh2en alt+z alt+z
Samge Translate:中译英并替换-zh2enReplace ctrl+shift+alt+z ctrl+shift+alt+z
Samge Translate:中文转变量名-zh2var shift+alt+w shift+alt+w

Configuration Options

Setting Type Default Value Description
samge.translate.enable boolean true Enables/Disables the plugin
samge.translate.enableHover boolean false Enables automatic translation on mouse hover
samge.translate.enableOutput boolean true Displays translations in the OUTPUT window
samge.translate.enableRightDisplay boolean true Shows translation results next to the selected text
samge.translate.languageFrom string en Source language for translation
samge.translate.languageTo string zh Target language for translation
samge.translate.providerName string baidu Translation engine provider
samge.translate.providerAppId string AppId for the translation engine
samge.translate.providerAppSecret string AppSecret for the translation engine
samge.translate.limitSingleMaximum integer 1000 Maximum character limit per translation

Editing Keyboard Shortcuts and Configuration

Follow these steps to modify keyboard shortcuts and settings:

  1. Edit Keyboard Shortcuts: In VSCode, go to File > Preferences > Keyboard Shortcuts to set up your shortcuts(searchable keyword samge to quickly locate relevant configuration items).
  2. Edit Configuration: In VSCode, navigate to File > Preferences > Settings > Extensions > Vscode Samge Translate Configuration for configuration options(searchable keyword samge to quickly locate relevant configuration items).

Common Questions

  • How to obtain appId and appSecret?

    • Baidu: 50,000 free characters/month (personal authentication allows for an upgrade to the advanced version: 1,000,000 free characters/month)
    • Alibaba: 1,000,000 free characters/month
    • Tencent: 5,000,000 free characters/month
    • Volcano Engine: 2,000,000 free characters/month
    • Youdao: New accounts receive a fixed free experience quota of 50 CNY
    • DeepL: 500,000 free characters/month
  • What translation engines are currently supported?

    • Baidu (baidu)
    • Alibaba (alibaba)
    • Tencent (tencent)
    • Volcano Engine (volcano)
    • Youdao (youdao)
    • DeepL (deepl)
  • What translation languages are currently supported?

    • English (en)
    • Chinese (zh)

Release Notes

Click Here To View Release Notes>>


Contributions

If you have any suggestions or code contributions, please feel free to submit issues or pull requests via the GitHub repository.

Copyright and License

This VSCode plugin is released under the MIT License.

Related Screenshots

automatically cache translation engine configuration parameters for easy switching: SamgeTranslateConfigAutoCache

Various display styles for translations: TranslateDisplayStyle

Chinese to variable name conversion (supports converting mixed Chinese/English or pure English into different camelCase rules): TestCustomVariables

Customizing keyboard shortcuts gif: KeyboardShortcuts.gif

Customizing keyboard shortcuts: KeyboardShortcuts

Configuration information gif: ExtensionsVscodeSamgeTranslateConfiguration.gif

Configuration information: ExtensionsVscodeSamgeTranslateConfiguration

Add the feature to convert consecutive Chinese characters to English on the left side of the cursor (This feature is not enabled by default; it needs to be activated by selecting the option within the plugin settings.): KeyboardShortcutsAndZh2varNew

KeyboardShortcutsAndZh2varNew

Dev

click here to view plugin development related content>>

Technical Communication

About

Vscode Samge Translate 翻译助手:Quickly translate text right in your code 🚀 支持多种翻译命令(英译中、中译英、中文转多规则命名变量等),支持多种结果展示方式,支持配置百度、阿里、腾讯、火山、有道、DeepL翻译引擎。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published