Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectText ¶
func DetectText(t Translator) ([]string, error)
func TranslateText ¶
func TranslateText(t Translator) (string, error)
func TranslateTexts ¶
func TranslateTexts(t Translator) ([]string, error)
Types ¶
type Access ¶
type Access interface {
GetAccessToken() TokenResponse
}
type AuthRequest ¶
func (*AuthRequest) GetAccessToken ¶
func (a *AuthRequest) GetAccessToken() TokenResponse
Make a POST request to `datamark` url for getting access token
type TextTranslate ¶
type TextTranslate struct {
Text string
Texts []string
From string
To string
Cache bool
TokenResponse
}
func (*TextTranslate) DetectTextArray ¶
func (t *TextTranslate) DetectTextArray() ([]string, error)
Detects the language of the text passed in the array `t.Texts`
func (*TextTranslate) Translate ¶
func (t *TextTranslate) Translate() (string, error)
Return `t.Text` in `t.From` language translated for `t.To` language
func (*TextTranslate) TranslateArray ¶
func (t *TextTranslate) TranslateArray() ([]string, error)
Return `t.Texts` array in `t.From` language translated for `t.To` language
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type,omitempty"`
ExpiresIn string `json:"expires_in"`
Scope string `json:"scope"`
Timeout time.Time `json:"timeout"`
}
func GetAccessToken ¶
func GetAccessToken(access Access) TokenResponse
func (*TokenResponse) CheckTimeout ¶
func (t *TokenResponse) CheckTimeout() bool
Verify if access token is valid
type TranslateResponse ¶
type TranslateResponse struct {
Resp []ArrayResp `xml:"TranslateArrayResponse"`
}
Click to show internal directories.
Click to hide internal directories.