deepl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURLPro  = "https://api.deepl.com/v2"
	BaseURLFree = "https://api-free.deepl.com/v2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string, authKey string, timeout time.Duration) *Client

type HTTPError

type HTTPError struct {
	StatusCode int
}

func (HTTPError) Error

func (err HTTPError) Error() string

type Language added in v0.2.0

type Language struct {
	Code              string `json:"language"`
	Name              string `json:"name"`
	SupportsFormality bool   `json:"supports_formality"`
}

type TranslateOption

type TranslateOption func(url.Values)

func Formality

func Formality(formality string) TranslateOption

Sets whether the translated text should lean towards formal or informal language.

func GlossaryId

func GlossaryId(glossary string) TranslateOption

Specify the glossary to use for the translation.

func IgnoreTags

func IgnoreTags(tags string) TranslateOption

Comma-separated list of XML tags that indicate text not to be translated.

func NonSplittingTags

func NonSplittingTags(tags string) TranslateOption

Comma-separated list of XML tags which never split sentences.

func OutlineDetection

func OutlineDetection(detect string) TranslateOption

Disable the automatic detection of the XML structure.

func PreserveFormatting

func PreserveFormatting(preserve string) TranslateOption

Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects.

func SourceLang

func SourceLang(lang string) TranslateOption

The language to be translated. If this parameter is omitted, the API will attempt to detect the language of the text and translate it.

func SplitSentences

func SplitSentences(split string) TranslateOption

Sets whether the translation engine should first split the input into sentences.

func SplittingTags

func SplittingTags(tags string) TranslateOption

Comma-separated list of XML tags which always cause splts.

func TagHandling

func TagHandling(handling string) TranslateOption

Sets which kind of tags should be handled.

type Translation

type Translation struct {
	DetectedSourceLanguage string `json:"detected_source_language"`
	Text                   string `json:"text"`
}

type Translator

type Translator struct {
	// contains filtered or unexported fields
}

func NewTranslator

func NewTranslator(authKey string, options TranslatorOptions) *Translator

func (*Translator) GetLanguages added in v0.2.0

func (t *Translator) GetLanguages(langType string) ([]Language, error)

func (*Translator) GetUsage added in v0.2.0

func (t *Translator) GetUsage() (*Usage, error)

func (*Translator) TranslateText

func (t *Translator) TranslateText(texts []string, targetLang string, options ...TranslateOption) ([]Translation, error)

The translate function.

type TranslatorOptions

type TranslatorOptions struct {
	ServerUrl string `default:""`
}

type Usage added in v0.2.0

type Usage struct {
	CharacterCount    int `json:"character_count"`
	CharacterLimit    int `json:"character_limit"`
	DocumentCount     int `json:"document_count"`
	DocumentLimit     int `json:"document_limit"`
	TeamDocumentCount int `json:"team_document_count"`
	TeamDocumentLimit int `json:"team_document_limit"`
}

Jump to

Keyboard shortcuts

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