-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gw31415/feature/doc
fix #1
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# DeepL.vim | ||
|
||
Provides functions to wrap the DeepL API. | ||
|
||
## Installation | ||
|
||
### 1. Installation of this plugin | ||
|
||
[Plug.vim](https://github.com/junegunn/vim-plug) | ||
```vim | ||
Plug 'gw31415/deepl.vim' | ||
``` | ||
|
||
[dein.vim](https://github.com/Shougo/dein.vim) | ||
```vim | ||
call dein#add('gw31415/deepl.vim') | ||
``` | ||
|
||
[packer.nvim](https://github.com/wbthomason/packer.nvim) | ||
```lua | ||
use 'gw31415/deepl.vim' | ||
``` | ||
|
||
### 2. Configuration of Auth Key | ||
|
||
```vim | ||
let g:deepl_auth_key = '{Your auth key of DeepL API}' | ||
``` | ||
|
||
## Example | ||
Create a command `:{range}DeepL` that translates the selected lines and adds the translation just below the selection. | ||
If the command called with a exclamation mark(`:{range}DeepL!`), the lines will be replaced with the translation. | ||
|
||
```vim | ||
fu! s:deepl(l1, l2, bang) abort | ||
let in = join(getline(a:l1, a:l2), "\n") | ||
let out = split(deepl#translate(in, 'EN'), "\n") | ||
if a:bang == '' | ||
cal append(a:l2, out) | ||
el | ||
cal setline(a:l1, out) | ||
en | ||
endfu | ||
com! -range -bang DeepL cal s:deepl(<line1>, <line2>, '<bang>') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
*DeepL.vim* *deepl.vim* | ||
Author: Amadeus_vn<git@amas.dev> | ||
License: zlib License | ||
|
||
|DeepL.vim| provides functions to wrap the DeepL API. | ||
|
||
============================================================================ | ||
Functions | ||
|
||
deepl#translate({text}, {target_lang}) *deepl#transllate()* | ||
|
||
Translates {text} to {target_lang} and returns the translation result. | ||
|
||
|
||
============================================================================ | ||
Variables | ||
|
||
*g:deepl_auth_key* Your Auth Key to access DeepL API. | ||
(Initially, this variable is not declared.) | ||
|
||
*g:deepl_endpoint* The Endpoint URL of DeepL API. | ||
(Default: 'https://api-free.deepl.com/v2/translate') | ||
|
||
============================================================================ | ||
Example | ||
|
||
In the example below, the command `:{range}DeepL` is created that translates | ||
the selected lines and adds the translation just below the selection. If the | ||
command called with a exclamation mark ( `:{range}DeepL!` ), the lines will be | ||
replaced with the translation. | ||
> | ||
fu! s:deepl(l1, l2, bang) abort | ||
let in = join(getline(a:l1, a:l2), "\n") | ||
let out = split(deepl#translate(in, 'EN'), "\n") | ||
if a:bang == '' | ||
cal append(a:l2, out) | ||
el | ||
cal setline(a:l1, out) | ||
en | ||
endfu | ||
com! -range -bang DeepL cal s:deepl(<line1>, <line2>, '<bang>') | ||
< | ||
|
||
vim:tw=78:ts=8:noet:ft=help:norl: |