A VS Code extension that translates non-English code comments into English inline, directly in your editor, using a locally-running Ollama LLM. No data leaves your machine.
Features
Translates comments from any language into English
Supports all common comment styles: //, #, --, %, ;, /* */, <!-- -->
Handles full-line comments, inline comments after code, and multi-line block comments
Displays translations as inline decorations next to the original comment — similar to GitLens blame annotations
Skips code lines and English comments automatically — only foreign language comments are shown
Works on the cursor line with no selection required
Can translate a selection, the entire file, or the entire workspace
Requirements
Ollama installed and running with at least one model pulled (e.g. ollama pull gpt-oss:20b)
VS Code 1.85.0 or later
Installation
Install VSTranslate from the VS Code Marketplace, or manually from a .vsix file:
Open VS Code and go to the Extensions view (Ctrl+Shift+X)
Click the ... menu at the top right and select Install from VSIX...
Select the downloaded file
Configuration
VSTranslate can be configured via Settings → Extensions → VSTranslate or directly in settings.json.
Setting
Default
Description
vstranslate.ollamaEndpoint
http://127.0.0.1:11434
Base URL of the Ollama API
vstranslate.ollamaModel
gpt-oss:20b
Ollama model to use for translation
vstranslate.ollamaApiKey
(empty)
API key, if your Ollama instance requires one
vstranslate.ollamaTimeout
30
Request timeout in seconds (-1 for no timeout)
vstranslate.overlayColor
#4EC9B0
Hex color for the inline translation text
To quickly switch models, open the Command Palette (Ctrl+Shift+P) and run VSTranslate: Select Ollama Model — this queries your Ollama instance and lets you pick from available models.
Usage
Place your cursor on a comment line, or select a block of code containing comments
Press Ctrl+Shift+T (macOS: Cmd+Shift+T), or right-click and choose one of:
Translate Selection to English — shows translations as inline decorations without modifying the file
Replace Comments with Translation — overwrites the original comment text in place
Insert Translated Comments — inserts the translation before the original comment text
Translations appear inline at the end of each non-English comment line
Moving the cursor or changing the selection clears the overlays
To clear manually, open the Command Palette (Ctrl+Shift+P) and run VSTranslate: Clear Translation Overlay
Translating a whole file or workspace
Open the Command Palette (Ctrl+Shift+P) and run:
VSTranslate: Translate File — translates all comments in the active file; prompts for replace or insert mode, with an Undo notification on completion
VSTranslate: Translate Workspace — translates all recognized source files in the workspace; shows a cancellable progress bar and an Undo notification on completion
How It Works
When you trigger a translation:
VSTranslate scans the selected lines (or cursor line) and extracts comment text — full-line comments, inline comments after code, and multi-line block comments
If a selection partially overlaps a block comment, the range is automatically expanded to include the entire block
Only comment text is sent to Ollama; code lines are ignored entirely
Ollama is instructed to return each line unchanged if it is already in English
Lines returned unchanged are silently dropped — only translated lines get a decoration
Each translation is displayed as an italic overlay anchored to the end of its source line