Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

translate.nvim

Highly configurable translation plugin for neovim.

More neovim plugins

Feature

  • multiple input methods
  • multiple output methods
  • invoke any translation engine via shell command
  • async job: never block your work

Dependencies

Usage

local function trans_to_zh()
	require("translate").translate({
		get_command = function(input)
			return {
				"trans",
				"-e",
				"bing",
				"-b",
				":zh",
				input,
			}
		end,
        -- input | clipboard | selection
		input = "selection",
        -- open_float | notify | copy | insert | replace
		output = { "open_float" },
		resolve_result = function(result)
			if result.code ~= 0 then
				return nil
			end

			return string.match(result.stdout, "(.*)\n")
		end,
	})
end

local function trans_to_en()
	require("translate").translate({
		get_command = function(input)
			return {
				"trans",
				"-e",
				"bing",
				"-b",
				":en",
				input,
			}
		end,
		input = "selection",
		output = { "replace" },
		resolve_result = function(result)
			if result.code ~= 0 then
				return nil
			end

			return string.match(result.stdout, "(.*)\n")
		end,
	})
end

About

Highly configurable translation plugin for neovim.

Topics

Resources

Stars

40 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages