Skip to content

ask-786/translate.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Neovim Google Translate Plugin

A lightweight Neovim plugin to translate selected or entered text using the Google Translate API. Supports translating between any languages, visual mode integration, and auto-detecting the source language.

✨ Features

  • Translate selected text in visual mode or manual input in normal mode
  • Prompts for source and target languages (or preconfigure them)
  • Works asynchronously using curl and vim.fn.jobstart
  • Displays translation result using vim.notify
  • Easy to configure with your API key

πŸ”§ Installation

Using lazy.nvim

{
  "ask-786/translate.nvim",
  config = function()
    require("translate").setup({
      key = os.getenv("GOOGLE_TRANSLATE_API_KEY"),
      translate_from = "auto",  -- Optional: default source language
      translate_to = "en",      -- Optional: default target language
    })
  end,
}

πŸ› οΈ Setup

require("translate").setup({
  key = "YOUR_GOOGLE_TRANSLATE_API_KEY", -- or use os.getenv("...")
  translate_from = nil,  -- Optional: "fr", "ja", or "auto". If nil, you will be prompted.
  translate_to = nil,    -- Optional: "en", "de", etc. If nil, you will be prompted.
})

πŸ“– Usage

Visual Mode

  1. Select some text.

  2. Run Lua command:

    :lua require("translate").translate()

Normal Mode

  1. Just run:

    :lua require("translate").translate()
  2. You’ll be prompted to enter text, source language, and target language.


βœ… Example

Input (in French):

Bonjour, comment allez-vous ?

Output:

Translation: Hello, how are you?

πŸ“Œ Requirements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages