go-deepl

module
v0.0.0-...-7296226 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2023 License: MIT

README

Go Reference

go-deepl

go-deepl is a simple Go library for DeepL API client.

Note: It is a fork from deepl-go by shopper29 with some modifications. Such as security updates, replacing deprecated modules, code coverage, etc.

Usage

go get github.com/KEINOS/go-deepl
import "github.com/KEINOS/go-deepl/deepl"
Requirements

Examples

package main

import (
    "context"
    "fmt"

    "github.com/KEINOS/go-deepl/deepl"
)

func main() {
    // Create a client for free account of DeepL API (choices: deepl.APIFree,
    // deepl.APIPro, deepl.APICustom). The second arg is the logger. If nil,
    // the default logger is used. Which logs to stderr.
    cli, err := deepl.New(deepl.APIFree, nil)
    if err != nil {
        log.Fatal(err)
    }

    translateResponse, err := cli.TranslateSentence(
        context.Background(),
        "Hello", // Phrase to translate
        "EN",    // from English
        "JA",    // to Japanese
    )

    if err != nil {
        log.Fatal(err)
    } else {
        fmt.Printf("%+v\n", translateResponse)
    }
    // Output:
    // &{Translations:[{DetectedSourceLanguage:EN Text:こんにちは}]}
}

License and Authors

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL