Use Deepl's API to translate from the command line.
Get an API account on deepl.com.
Copy or symlink
deepl to a directory in your
# ~/.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.
From the command-line:
deepl -t FR <<< "Integrate the world’s 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
deepl is somewhere in your
$PATH, add this to your
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:
Or with a language of your choice:
:Translate -t RU