Ⅰ. 插件描述
:closed_book: Asynchronous translating plugin for Vim/NeovimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'voldikss/vim-translator-the-thing-itself'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'voldikss/vim-translator-the-thing-itself'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'voldikss/vim-translator-the-thing-itself'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/voldikss/vim-translator
Ⅳ. 文档说明
# vim-translator
Asynchronous translating plugin for Vim/Neovim
<div align="center">
<img src="https://user-images.githubusercontent.com/20282795/71441598-19596a00-273d-11ea-841e-dc893fc9ae7d.gif" width=750></div>
<div align="center">
<img src="https://user-images.githubusercontent.com/20282795/71441597-18c0d380-273d-11ea-9248-ae71b2a7ea42.gif" width=750></div>
<div align="center">
<img src="https://user-images.githubusercontent.com/20282795/71475802-da9ae100-281c-11ea-9eba-c8c4eee04bd9.png" width=750></div>
Installation
Plug 'voldikss/vim-translator'Features
- 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
Configuration
g:translator_target_lang
Target language
- Available: Please refer to language support list
- Default:
'zh'
g:translator_source_lang
Source language
- Available: Please refer to language support list
- Default:
'auto'
g:translator_default_engines
- Available:
'bing','ciba','google','youdao','trans' - Default:
['ciba', 'youdao']ifg:translator_target_langis'zh', otherwise['google', 'bing']
g:translator_proxy_url
e.g.
let g:translator_proxy_url = 'socks5://127.0.0.1:1080'
- Default:
v:null
g:translator_history_enable
- Default:
v:false
g:translator_window_type
- Available:
'popup'(use floatwin in nvim or popup in vim),'preview' - Default:
'popup'
g:translator_window_max_width
Max width value of the popup/floating window
- Default:
0.6*&columns
g:translator_window_max_height
Max height value of popup/floating window
- Default:
0.6*&lines
g:translator_window_borderchars
Floating window border will be disabled if
g:translator_window_bordercharsisv:null
- Default:
['─', '│', '─', '│', '┌', '┐', '┘', '└']
g:translator_window_enable_icon
Set it to
v:falseif your terminal doesn't support Unicode symbols
- Default:
v:true
Key Mappings
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
Commands
:Translate[!] [-e engines] [-t text] [-tl target_lang] [-sl source_lang]
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
:TranslateW[!] [-e engines] [-t text] [-tl target_lang] [-sl source_lang]
Like :Translate..., but display the translation in a window
:TranslateR[!] [-e engines] [-t text] [-tl target_lang] [-sl source_lang]
Like :Translate..., but replace the current text with the translation
:TranslateH
Export the translation history
Example:
:TranslateW -t text -e bing youdao -tl zh -sl enHighlight
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 NormalFloatKnown bugs
- Can not translate sentences(because there are some spaces among words) in Vim8(see #24)
FAQ
Can not find python executable?
Set g:python3_host_prog variable in your vimrc. e.g.
let g:python3_host_prog = /path/to/python_executableReferences
License
MIT