Do you want to use google translator API? API is not free anymore. But you can translate 1000 words per day free. And then may be this project can help you to translate unlimited text from one language to another using Google Translator.
go-google-translate
provides a go
package to translate using Google Translator by parsing HTML. This library can be used to translate from any language to any other.
In addition this library provides a cli to translate text via console.
$ go get -u -v github.com/smirkcat/go-google-translate/...
package main
import (
"fmt"
"log"
trans "github.com/smirkcat/go-google-translate/pkg"
)
func main() {
// request struct
req := &trans.TranslateRequest{
SourceLang: "bn",
TargetLang: "en",
Text: "আমি বাংলায় গান গাই",
}
// translate
translated, err := trans.Translate(req)
if err != nil {
log.Fatalln(err)
}
fmt.Println(translated) // I sing in Bangla
}
Command line interface to translate text using command line.
$ go get -u -v github.com/aerokite/go-google-translate/cmd/gopret
$ go install github.com/aerokite/go-google-translate/cmd/gopret
$ gopret translate --sl bn --tl en --text "আমি বাংলায় গান গাই"
I sing in Bangla
Arnaud Aliès for mtranslate in python.
Copyright (c) 2017 Mir Shahriar
Licensed under MIT Licence.