Bing Translator
A simple and efficient VSCode extension for translating text using Bing Translator API.
Features
- Quick Translation: Translate text with keyboard shortcuts, context menu, or status bar button
- Two Translation Modes:
- Input Box Mode (Ctrl+Shift+T): Enter text in a dialog and view translation
- Selection Mode (Ctrl+Alt+T or right-click): Translate selected text in editor and optionally replace it
- Context Menu Integration: Right-click on selected text to translate
- Configurable Languages: Set your preferred source and target languages
- Status Bar Integration: Click the globe icon to translate, with dynamic tooltip showing current language pair
- Auto-detect: Supports automatic language detection
- Smart Error Handling: User-friendly error messages for common issues
Usage
- Press
Ctrl+Shift+T (Windows/Linux) or Cmd+Shift+T (Mac)
- Enter the text you want to translate
- Press Enter to see the translation result
- Copy the translation or press Esc to close
Method 2: Selection Translation (Ctrl+Alt+T)
- Select text in your editor
- Press
Ctrl+Alt+T (Windows/Linux) or Cmd+Alt+T (Mac)
- View the translation result
- Press Enter to replace the selection with translation, or Esc to keep original
- Select text in your editor
- Right-click on the selected text
- Click "Translate Selection" (or "翻译选中内容" in Chinese)
- View the translation result
- Press Enter to replace the selection with translation, or Esc to keep original
- Click the "$(globe) Translate" button in the status bar (bottom right)
- Enter the text you want to translate
- Press Enter to see the translation result
Configuration
You can configure the source and target languages in VSCode settings:
- Open Settings (File > Preferences > Settings)
- Search for "Bing Translator"
- Set your preferred languages:
- Source Language: Default is
en (English)
- Target Language: Default is
zh-Hans (Chinese Simplified)
Supported Language Codes
Common language codes:
en - English
zh-Hans - Chinese Simplified
zh-Hant - Chinese Traditional
ja - Japanese
ko - Korean
fr - French
de - German
es - Spanish
ru - Russian
ar - Arabic
pt - Portuguese
it - Italian
auto-detect - Auto-detect source language
For a complete list of 180+ supported languages, see src/languages.json.
Example Configuration
Add to your settings.json:
{
"bing-translator.sourceLanguage": "en",
"bing-translator.targetLanguage": "zh-Hans"
}
Commands
- Translate Text (
bing-translator.translate): Open input box to translate text
- Translate Selection (
bing-translator.translateSelection): Translate selected text in editor
Keyboard Shortcuts
Ctrl+Shift+T (Mac: Cmd+Shift+T): Open translation input box
Ctrl+Alt+T (Mac: Cmd+Alt+T): Translate selected text (when text is selected)
Installation
From Source
- Clone or download this repository
- Open the folder in VSCode
- Press F5 to run the extension in a new Extension Development Host window
- Test the translation feature
Package and Install
- Install vsce:
npm install -g @vscode/vsce
- Package the extension:
npm run build
- Install the .vsix file: Extensions > Install from VSIX
Requirements
- VSCode version 1.96.0 or higher
- Internet connection (for Bing Translator API)
Known Limitations
- Requires active internet connection
- Subject to Bing Translator rate limits
- May require captcha verification if used too frequently
- Maximum text length: ~1000 characters (Bing Translator limit)
Troubleshooting
"Translation limit exceeded"
This means you've hit Bing Translator's rate limit. Wait a few minutes and try again.
"Failed to connect to translation service"
Check your internet connection and firewall settings. Ensure you can access bing.com.
"Translation service requires verification"
Bing Translator is asking for captcha verification. Wait a while before trying again.
Status bar not showing
The extension activates on startup. If the status bar doesn't appear, try reloading VSCode.
Development
Building
npm run package
Publishing
npm run publish