This is Golang version of py-googletrans.
Googletrans is a free and unlimited Golang library that implemented Google Translate API. This uses the Google Translate Ajax API from Chrome extensions to make calls to such methods as detect and translate.
GO111MODULE=on go get github.com/Conight/go-googletrans
package main
import (
"fmt"
"github.com/Conight/go-googletrans"
)
func main() {
t := translator.New()
result, err := t.Translate("你好,世界!", "auto", "en")
if err != nil {
panic(err)
}
fmt.Println(result.Text)
}
c := translator.Config{
Proxy: "http://PROXY_HOST:PROXY_PORT",
}
t := translate.New(c)
c := translator.Config{
UserAgent: []string{"Custom Agent"},
ServiceUrls: []string{"translate.google.com.hk"},
}
t := translate.New(c)
See Examples for more examples.
This SDK is distributed under the The MIT License, see LICENSE for more information.