Asynchronous translating plugin for Vim/Neovim
Plug 'voldikss/vim-translator'- Asynchronous translating
- Floatwin(NeoVim) & popup(Vim8) support
- Multi engines: bing, ciba, google, youdao, translate-shell
- Save and export translation history
- Proxy support(http, socks4, socks5)
- No requirement for appid/appkey
Target language
-
Available: Please refer to language support list
-
Default:
'zh'
Source language
-
Available: Please refer to language support list
-
Default:
'auto'
-
Available:
'bing','ciba','google','youdao','trans' -
Default:
['ciba', 'youdao']ifg:translator_target_langis'zh', otherwise['google', 'bing']
e.g.
let g:translator_proxy_url = 'socks5://127.0.0.1:1080'
- Default:
v:null
- Default:
v:false
-
Available:
'popup'(use floatwin in nvim or popup in vim),'preview' -
Default:
'popup'
Max width value of the popup/floating window
- Default:
0.6*&columns
Max height value of popup/floating window
- Default:
0.6*&lines
Floating window border will be disabled if
g:translator_window_bordercharsisv:null
- Default:
['─', '│', '─', '│', '┌', '┐', '┘', '└']
Set it to
v:falseif your terminal doesn't support Unicode symbols
- Default:
v:true
This plugin doesn't supply any default mappings.
""" Configuration example
" Echo translation in the cmdline
nmap <silent> <Leader>t <Plug>Translate
vmap <silent> <Leader>t <Plug>TranslateV
" Display translation in a window
nmap <silent> <Leader>w <Plug>TranslateW
vmap <silent> <Leader>w <Plug>TranslateWV
" Replace the text with translation
nmap <silent> <Leader>r <Plug>TranslateR
vmap <silent> <Leader>r <Plug>TranslateRVOnce the translation window is opened, type <Leader>w again to jump into it and again to jump back
Translate the text from the source language source_lang to the target language target_lang with engine, echo the result in the cmdline
If no engines, use g:translator_default_engines
If no text, use the text under the cursor
If no target_lang, use g:translator_target_lang
The command can also be passed to a range, i.e., :'<,'>Translate ..., which translates text in visual selection
If ! is included, the plugin will perform a reverse translating by switching target_lang and source_lang
Like :Translate..., but display the translation in a window
Like :Translate..., but replace the current text with the translation
Export the translation history
Example:
:TranslateW -t text -e bing youdao -tl zh -sl en
Here are the default highlight links. To customize, use hi or hi link
" Text highlight of translator window
hi def link TranslatorQuery Identifier
hi def link TranslatorPhonetic Type
hi def link TranslatorExplain Statement
hi def link TranslatorDelimiter Special
" Background of translator window border
hi def link TranslatorNF NormalFloat
hi def link TranslatorBorderNF NormalFloat- Can not translate sentences(because there are some spaces among words) in Vim8(see #24)
-
Set
g:python3_host_progvariable in your vimrc. e.g.let g:python3_host_prog = /path/to/python_executable
MIT


