Skip to content

micheam/go-deeplapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-deeplapi

Usage

AS CLI TOOL

$ go install github.com/micheam/go-deeplapi/cmd/translate@latest
$ export DEEPL_AUTH_KEY="<YOUR-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

$ go get github.com/micheam/go-deeplapi/v2
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

$ go install github.com/micheam/go-deeplapi/cmd/translate

License

MIT

Author

Michito Maeda

About

Client library and cli app for deepl web api.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published