acs

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TranslationScope     = "translation"
	TransliterationScope = "transliteration"
	DictionaryScope      = "dictionary"
)

Variables

This section is empty.

Functions

func DetectUrl

func DetectUrl() *url.URL

func LanguagesUrl

func LanguagesUrl(scopes ...string) *url.URL

func NewTranslator

func NewTranslator(hc *http.Client, key string) (polyglot.Translator, error)

func TranslateUrl

func TranslateUrl(from, to string, format polyglot.TranslateFormat) *url.URL

Types

type DetectResponse

type DetectResponse struct {
	Language                   string  `json:"language"`
	Score                      float64 `json:"score"`
	IsTranslationSupported     bool    `json:"isTranslationSupported"`
	IsTransliterationSupported bool    `json:"isTransliterationSupported"`
}

func Detect

func Detect(hc *http.Client, content, key string) (*DetectResponse, error)

func Detects

func Detects(hc *http.Client, key string, content ...string) ([]*DetectResponse, error)

type TextData

type TextData struct {
	Text string `json:"text"`
}

func NewTextData

func NewTextData(content ...string) []TextData

type Translation

type Translation struct {
	Text string `json:"text"`
	To   string `json:"to"`
}

type TranslationLanguage

type TranslationLanguage struct {
	Name       string `json:"name"`
	NativeName string `json:"nativeName"`
	Dir        string `json:"dir"`
}

type TranslationLanguagesResponse

type TranslationLanguagesResponse struct {
	Translation map[string]TranslationLanguage `json:"translation"`
}

func TranslationLanguages

func TranslationLanguages(hc *http.Client, acceptLanguage string) (*TranslationLanguagesResponse, error)

type TranslationsResponse

type TranslationsResponse struct {
	Translations []Translation `json:"translations"`
}

func Translate

func Translate(hc *http.Client, content []string, from, to string, format polyglot.TranslateFormat, key string) ([]*TranslationsResponse, error)

type Translator

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

func (*Translator) Detect

func (t *Translator) Detect(content string) (string, error)

func (*Translator) IsHTMLSupported

func (t *Translator) IsHTMLSupported() bool

func (*Translator) Languages

func (t *Translator) Languages(language string) (map[string]string, error)

func (*Translator) Translate

func (t *Translator) Translate(source, target string, format polyglot.TranslateFormat, query ...string) ([]string, error)

Jump to

Keyboard shortcuts

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