Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTranslator ¶
func NewTranslator(subscriptionKey string) translator.Translator
NewTranslator returns a struct that implements the Translator interface by exposing a Translate and a Languages function that are backed by Microsoft's translation API. The function takes the subscriptionKey for a registered Text Translation Service. Details on how to get such a key: http://docs.microsofttranslator.com/text-translate.html.
Types ¶
type Alternatives ¶
type Detect ¶
type Detect []struct { Language string `json:"language"` Score float64 `json:"score"` IsTranslationSupported bool `json:"isTranslationSupported"` IsTransliterationSupported bool `json:"isTransliterationSupported"` Alternatives []Alternatives `json:"alternatives"` }
type LanguageCatalog ¶
type LanguageCatalog interface {
Languages() ([]translator.Language, error)
}
The LanguageCatalog provides a slice of languages representing all languages supported by Microsoft's Translation API.
type LanguageProvider ¶
type LanguageProvider interface { Codes() ([]string, error) Names(codes []string) ([]string, error) }
The LanguageProvider retrieves the names and codes of all languages supported by Microsoft's Translation API.
type Router ¶
type Router interface { AuthURL() string TranslationURL() string DetectURL() string LanguageNamesURL() string LanguageCodesURL() string ApiVersion() string }
The Router provides necessary URLs to communicate with Microsoft's API.
type Translate ¶
type Translate []struct { Translations []Translations `json:"translations"` }
type TranslationProvider ¶
type TranslationProvider interface { Translate(text, from, to, version string) (string, error) Detect(text, version string) (string, error) }
The TranslationProvider communicates with Microsoft's API to provide a translation for a given text.