Skip to content

This is a an unofficial Go SDK for using the DeepL API.

License

Notifications You must be signed in to change notification settings

EYERCORD/deepl-sdk-go

 
 

Repository files navigation

deepl-sdk-go

This is an unofficial Go SDK for using the DeepL API.

Usage

go get github.com/EYERCORD/deepl-sdk-go

Sample

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/michimani/deepl-sdk-go"
	"github.com/michimani/deepl-sdk-go/params"
	"github.com/michimani/deepl-sdk-go/types"
)

func main() {
	client, err := deepl.NewClient()
	if err != nil {
		fmt.Println(err)
		return
	}

	text := []string{
		"Привіт",
		"Це приклад тексту",
	}
	params := &params.TranslateTextParams{
		TargetLang: types.TargetLangEN,
		Text:       text,
	}

	res, errRes, err := c.TranslateText(context.TODO(), params)

	if err != nil {
		fmt.Println(err)
	}

	if errRes != nil {
		fmt.Println("ErrorResponse", errRes.Message)
	}

	for i := range res.Translations {
		fmt.Printf("%s -> %s\n", text[i], res.Translations[i].Text)
	}
}

About

This is a an unofficial Go SDK for using the DeepL API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%