Documentation ¶
Index ¶
- Constants
- type Authenticator
- type Client
- func (c *Client) Detect(text string) (string, error)
- func (c *Client) DetectArray(text []string) ([]string, error)
- func (c *Client) GetLanguageNames(codes []string) ([]string, error)
- func (c *Client) GetLanguagesForSpeak() ([]string, error)
- func (c *Client) GetLanguagesForTranslate() ([]string, error)
- func (c *Client) GetTranslations(text, from, to string, maxTranslations int) ([]ResponseTranslationMatch, error)
- func (c *Client) Speak(text, lang, outFormat string) ([]byte, error)
- func (c *Client) TransformText(lang, category, text string) (string, error)
- func (c *Client) Translate(text, from, to string) (string, error)
- type GetTranslationResponse
- type LanguageProvider
- func (l *LanguageProvider) Detect(text string) (string, error)
- func (l *LanguageProvider) DetectArray(text []string) ([]string, error)
- func (l *LanguageProvider) GetLanguageNames(codes []string) ([]string, error)
- func (l *LanguageProvider) GetLanguagesForSpeak() ([]string, error)
- func (l *LanguageProvider) GetLanguagesForTranslate() ([]string, error)
- func (l *LanguageProvider) GetTranslations(text, from, to string, maxTranslations int) ([]ResponseTranslationMatch, error)
- type ResponseArray
- type ResponseToken
- type ResponseTranslationMatch
- type ResponseTranslations
- type ResponseXML
- type TransformTextResponse
- type TranslateProvider
- type XMLIntValue
- type XMLStringValue
Constants ¶
View Source
const ( API_URL = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/" API_SCOPE = "http://api.microsofttranslator.com" TransformTextURL = "http://api.microsofttranslator.com/V3/json/TransformText" ServiceURL = "http://api.microsofttranslator.com/v2/Http.svc/" TranslationURL = ServiceURL + "Translate" GetTranslationsURL = ServiceURL + "GetTranslations" DetectURL = ServiceURL + "Detect" DetectArrayURL = ServiceURL + "DetectArray" SpeakURL = ServiceURL + "Speak" GetLanguageNamesURL = ServiceURL + "GetLanguageNames" GetLanguagesForTranslateURL = ServiceURL + "GetLanguagesForTranslate" GetLanguagesForSpeakURL = ServiceURL + "GetLanguagesForSpeak" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
func NewAuthenticator ¶
func NewAuthenticator(cid, csecret string) *Authenticator
func (*Authenticator) GetToken ¶
func (auth *Authenticator) GetToken() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetLanguageNames ¶
func (*Client) GetLanguagesForSpeak ¶
func (*Client) GetLanguagesForTranslate ¶
func (*Client) GetTranslations ¶
func (c *Client) GetTranslations(text, from, to string, maxTranslations int) ([]ResponseTranslationMatch, error)
func (*Client) TransformText ¶
type GetTranslationResponse ¶
type GetTranslationResponse struct { XMLName xml.Name `xml:"GetTranslationResponse"` Translations ResponseTranslations `xml:"Translations"` }
type LanguageProvider ¶
type LanguageProvider struct {
// contains filtered or unexported fields
}
func NewLanguageProvider ¶
func NewLanguageProvider(auth *Authenticator) *LanguageProvider
func (*LanguageProvider) DetectArray ¶
func (l *LanguageProvider) DetectArray(text []string) ([]string, error)
func (*LanguageProvider) GetLanguageNames ¶
func (l *LanguageProvider) GetLanguageNames(codes []string) ([]string, error)
Retrieves friendly names for the languages passed in as the parameter languageCodes, and localized using the passed locale language.
func (*LanguageProvider) GetLanguagesForSpeak ¶
func (l *LanguageProvider) GetLanguagesForSpeak() ([]string, error)
func (*LanguageProvider) GetLanguagesForTranslate ¶
func (l *LanguageProvider) GetLanguagesForTranslate() ([]string, error)
func (*LanguageProvider) GetTranslations ¶
func (l *LanguageProvider) GetTranslations(text, from, to string, maxTranslations int) ([]ResponseTranslationMatch, error)
type ResponseArray ¶
type ResponseToken ¶
type ResponseTranslationMatch ¶
type ResponseTranslationMatch struct { Count XMLIntValue `xml:"Count"` MatchDegree XMLIntValue `xml:"MatchDegree"` MatchedOriginalText XMLStringValue `xml:"MatchedOriginalText"` Rating XMLIntValue `xml:"Rating"` TranslatedText XMLStringValue `xml:"TranslatedText"` }
type ResponseTranslations ¶
type ResponseTranslations struct {
TransMatch []ResponseTranslationMatch `xml:"TranslationMatch"`
}
type ResponseXML ¶
type TransformTextResponse ¶
type TranslateProvider ¶
type TranslateProvider struct {
// contains filtered or unexported fields
}
func NewTranslateProvider ¶
func NewTranslateProvider(auth *Authenticator) *TranslateProvider
func (*TranslateProvider) Speak ¶
func (t *TranslateProvider) Speak(text, lang, outFormat string) ([]byte, error)
func (*TranslateProvider) TransformText ¶
func (t *TranslateProvider) TransformText(lang, category, text string) (string, error)
type XMLIntValue ¶
type XMLIntValue struct {
Text int `xml:",chardata"`
}
type XMLStringValue ¶
type XMLStringValue struct {
Text string `xml:",chardata"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.