Translation extension for coc.nvim. Inspired by vim-translator
:CocInstall coc-translator
NOTE: No need to install vim-translator
- Multiple translator engines
- Export translation history
- View and process translation history via CocList
- Proxy support(see coc.nvim doc)
"translator.toLang": {
"type": "string",
"default": "zh",
"description": "Target language"
},
"translator.engines": {
"type": "array",
"default": [
"bing",
"google",
"youdao",
"haici"
]
},
"translator.enableHover": {
"type": "boolean",
"default": false,
"description": "Enable on hover translating"
},
"translator.maxsize": {
"type": "number",
"default": 5000,
"description": "Max history count"
},
"translator.window.maxWidth": {
"type": "number",
"default": 999
},
"translator.window.maxHeight": {
"type": "number",
"default": 999
}
more information, see package.json
engine | supported language types |
---|---|
bing | ref |
iciba(deprecated) | ref |
ref | |
youdao | ref |
haici |
Example
" popup
nmap <Leader>t <Plug>(coc-translator-p)
vmap <Leader>t <Plug>(coc-translator-pv)
" echo
nmap <Leader>e <Plug>(coc-translator-e)
vmap <Leader>e <Plug>(coc-translator-ev)
" replace
nmap <Leader>r <Plug>(coc-translator-r)
vmap <Leader>r <Plug>(coc-translator-rv)
:CocCommand translator.popup [text]
Display translation result via floating/popup window:CocCommand translator.echo [text]
Echo the translation result in the cmdline:CocCommand translator.replace [text]
Replace the word under the cursor with the translation:CocCommand translator.exportHistory
Export translation history in the tabpage
Note: [text]
is optional, if no text
, the extension will use the <word>
under the cursor.
run :CocList translation
to open the translation list.
- Filter your translation items and perform operations via
<Tab>
- Use operation
delete
to delete the translation item under the cursor - Use operation
yank
to yank ... - Use operation
open
to open the file which contains the query word - Use operation
preview
to preview ... - Use operation
append
to append the word to the end of cursor position - Use operation
pretend
to pretend ...
For more advance usage, checkout :h coc-list
Q: Where are the translation data stored?
A: Normally the data is saved in ~/.config/coc/extensions/coc-translation-data
, but if you set g:coc_extension_root
to another location, it will change as well
MIT