Translate with Deepl from the command-line or in vim
Go to file
Pierre Prinetti 6f67a681fd
Rename the license file
2023-07-05 14:40:49 +02:00
LICENSE.txt Rename the license file 2023-07-05 14:40:49 +02:00
README.md vim command 2023-07-05 14:26:44 +02:00
deepl fix: Stop appending newlines to the output 2023-07-05 13:57:42 +02:00

README.md

deepl

Use Deepl's API to translate from the command line.

Get an API account on deepl.com.

Requirements

Install

Copy or symlink deepl to a directory in your $PATH, like ~/.local/bin/.

Configuration

# ~/.config/deepl/config
# The default target language is used when not using the command line flag `-t`
#default_target_lang=DE

# The API key can either be set directly, or fetched on-the-fly from a command
#deepl_key='abcabcabc'
#deepl_key="$(pass show deepl)"

# Set to 'api.deepl.com' to use a paid plan
#deepl_host=api-free.deepl.com

All the examples below assume that you have set the API key in the config file. Otherwise, add a -k <key> argument.

Usage

From the command-line:

deepl -t FR <<< "Integrate the worlds best machine translation technology directly into your own products and platforms."

Replace the current Vim buffer with its French translation:

:% !deepl -t FR

Set a command in Vim or neovim

Once deepl is somewhere in your $PATH, add this to your init.vim:

command -nargs=? -range=% Translate <line1>,<line2>!deepl <args>

Then you can replace the whole current buffer (or just the selected lines) with its translation to the default target_lang:

:Translate

Or with a language of your choice:

:Translate -t RU