Documentation ¶
Index ¶
- Constants
- Variables
- func AsyncTranslate(eachTranslatorTimeout time.Duration, req *Request, ts ...string) <-chan *Response
- func IsChinese(str string) bool
- type Request
- type Response
- func BaiduTranslate(ctx context.Context, req Request) (resp *Response)
- func BingTranslate(ctx context.Context, req Request) *Response
- func CaiyunTranslate(ctx context.Context, req Request) *Response
- func DeeplTranslate(ctx context.Context, req Request) *Response
- func GoogleTranslate(ctx context.Context, req Request) *Response
- func SogouTranslate(ctx context.Context, req Request) *Response
- func TencentTranslate(ctx context.Context, req Request) *Response
- func YoudaoTranslate(ctx context.Context, req Request) *Response
Constants ¶
View Source
const ( Chinese = "zh-CN" English = "en" Russian = "ru" Japanese = "ja" German = "de" French = "fr" Korean = "ko" Spanish = "es" UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" )
Variables ¶
View Source
var Translators = []translator{
baidu, bing, google, sogou, tencent, youdao, deepl, caiyun,
}
Functions ¶
func AsyncTranslate ¶ added in v0.4.5
Types ¶
type Request ¶
type Request struct { // FromLang the from language of the translation FromLang string // ToLang the to language of the translation ToLang string // Text translation text Text string }
Request translation request
type Response ¶
type Response struct { // Name the translator name Name string // Homepage the translator homepage Homepage string // Result the translation result Result string // Err the translation error Err error }
Response translation response
func BaiduTranslate ¶ added in v0.4.5
func CaiyunTranslate ¶ added in v0.6.0
func DeeplTranslate ¶ added in v0.5.0
func GoogleTranslate ¶ added in v0.4.5
func SogouTranslate ¶ added in v0.4.5
func TencentTranslate ¶ added in v0.4.5
Source Files ¶
Click to show internal directories.
Click to hide internal directories.