https://github.com/micheam/go-deeplapi
Client library and cli app for deepl web api.
https://github.com/micheam/go-deeplapi
cli-app deepl deepl-api go-library translation
Last synced: 8 months ago
JSON representation
Client library and cli app for deepl web api.
- Host: GitHub
- URL: https://github.com/micheam/go-deeplapi
- Owner: micheam
- License: mit
- Created: 2021-08-26T15:10:32.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-17T07:35:13.000Z (over 3 years ago)
- Last Synced: 2025-06-22T16:41:26.282Z (12 months ago)
- Topics: cli-app, deepl, deepl-api, go-library, translation
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-deeplapi
## Usage
### AS CLI TOOL
```sh
$ go install github.com/micheam/go-deeplapi/cmd/translate@latest
```
```sh
$ export DEEPL_AUTH_KEY=""
$ export DEEPL_API_DOMEIN="api-free.deepl.com" # for free plan
$ translate こんにちわ、世界
Hello, World
```
Please run `-help` for detailed usage.
```
$ translate -help
Usage of translate:
translate [flags] [text]
Flags:
--api-domain string
Domain for DeepL API. (Default) Environment variable: 'DEEPL_API_DOMAIN'
Use 'api.deepl.com' if not set.
--auth-key string
Authentication Key for DeepL API. (Default) Environment variable: 'DEEPL_AUTH_KEY'
--list-lang
Display a list of LANG_CODE that can be specified.
--source string
LANG_CODE of the text to be translated. If it is omitted, it will be determined automatically.
--target string
LANG_CODE of the text to be translated. (default 'EN')
Examples:
$ translate --soruce ja --taget en 'あんなこといいな。できたらいいな'
$ echo 'あんなこといいな。できたらいいな' | translate # source lang will auto-detected
```
### AS GO MODULE
```sh
$ go get github.com/micheam/go-deeplapi/v2
```
```go
package main
import (
"context"
"fmt"
"github.com/micheam/go-deeplapi/v2"
)
func main() {
const authKey = "YOUR-DEEPL-AUTH-KEY"
client := deeplapi.New(authKey)
service := deeplapi.NewTextTranslatingService(client)
var (
text = "こんにちわ、世界"
source = deeplapi.LangJapanese
target = deeplapi.LangEnglish
)
res, _ := service.TraslateSingleText(context.Background(), text, source, target)
fmt.Println(res.Text)
// Output: Hello, World
}
```
## Requirements
- go 1.19 or higher
## Installation
```sh
$ go install github.com/micheam/go-deeplapi/cmd/translate
```
## License
MIT
## Author
[Michito Maeda](https://github.com/micheam)