Translate comments and strings directly in Neovim using hover or immersive inline views. Supports classic translation APIs as well as LLM backends, including fully local models via Ollama.

Many translation plugins rely on external services only. comment-translate.nvim is designed for teams and individuals who want a practical choice:
openai, anthropic, gemini, ollama)This plugin gives you control over where your text goes:
translate_service = 'google' or hosted llm providers: text is sent to the configured remote service.llm.provider = 'ollama' with the default local endpoint keeps translation local; if llm.endpoint is set to a remote host, text is sent there.For sensitive repositories, local Ollama models are the recommended setup.
curlNote: Internet is not required when you use local translation only (for example, Ollama running locally).
Parsers may come from bundled Neovim parsers, manual installation, or
parser-providing plugin setups such as nvim-treesitter.
comment-translate.nvim uses Neovim's built-in Tree-sitter APIs and does not
require the nvim-treesitter plugin itself.
{
'noir4y/comment-translate.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
config = function()
require('comment-translate').setup({})
end,
}
use {
'noir4y/comment-translate.nvim',
requires = {
'nvim-lua/plenary.nvim',
},
config = function()
require('comment-translate').setup({})
end,
}
If you already manage parsers through nvim-treesitter, you can keep doing so.
vim.keymap.set('n', '<leader>th', '<cmd>CommentTranslateHover<CR>', { silent = true })
:CommentTranslateToggle
:CommentTranslateReplace
require('comment-translate').setup({
target_language = 'ja',
translate_service = 'google', -- 'google' or 'llm'
hover = {
enabled = true,
delay = 500,
auto = true,
},
immersive = {
enabled = false,
},
cache = {
enabled = true,
max_entries = 1000,
},
targets = {
comment = true,
string = true,
},
llm = {
provider = 'ollama', -- 'openai' | 'anthropic' | 'gemini' | 'ollama'
model = 'translategemma:4b',
api_key = nil, -- not required for ollama
timeout = 20,
endpoint = 'http://localhost:11434/api/chat', -- optional
},
keymaps = {
hover = '<leader>th',
hover_manual = '<leader>tc',
replace = '<leader>tr',
toggle = '<leader>tt',
},
})
require('comment-translate').setup({
translate_service = 'llm',
llm = {
provider = 'ollama',
model = 'translategemma:4b',
},
})
require('comment-translate').setup({
translate_service = 'llm',
llm = {
provider = 'openai',
api_key = vim.env.OPENAI_API_KEY,
model = 'gpt-5.2',
},
})
:CommentTranslateHover — Display translation under cursor:CommentTranslateHoverToggle — Toggle auto hover on/off:CommentTranslateReplace — Replace selected text with translation:CommentTranslateToggle — Toggle immersive translation globally:CommentTranslateUpdate — Update immersive translation for current buffer:CommentTranslateSetup — Setup plugin with default settings:CommentTranslateHealth — Health check, including parser availability for the buffer that invoked itUse :checkhealth comment-translate for general dependency and configuration checks.
Use :CommentTranslateHealth from the file buffer you want to inspect when you
also want parser availability checked for that buffer.
make fmtmake fmt-checkmake lintmake testMIT