deepl

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KnownErrors = map[int]string{
	400: "Bad request. Please check error message and your parameters.",
	403: "Authorization failed. Please supply a valid auth_key parameter.",
	404: "The requested resource could not be found.",
	413: "The request size exceeds the limit.",
	414: "The request URL is too long. You can avoid this error by using a POST request instead of a GET request, and sending the parameters in the HTTP body.",
	429: "Too many requests. Please wait and resend your request.",
	456: "Quota exceeded. The character limit has been reached.",
	503: "Resource currently unavailable. Try again later.",
	529: "Too many requests. Please wait and resend your request.",

} // this from https://www.deepl.com/docs-api/accessing-the-api/error-handling/

Functions

func GetEndpoint

func GetEndpoint(IsPro bool) string

func ValidateResponse

func ValidateResponse(resp *http.Response) error

Types

type DeepL

type DeepL interface {
	Translate(Text string, sourceLang string, targetLang string)
}

type DeepLClient

type DeepLClient struct {
	Endpoint string
	AuthKey  string
}

func (*DeepLClient) Translate

func (c *DeepLClient) Translate(text string, sourceLang string, targetLang string) ([]string, error)

type DeepLResponse

type DeepLResponse struct {
	Translations []Translated
}

func ParseResponse

func ParseResponse(resp *http.Response) (DeepLResponse, error)

type Translated

type Translated struct {
	DetectedSourceLaguage string `json:"detected_source_language"`
	Text                  string `json:"text"`
}

Jump to

Keyboard shortcuts

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