gtranslate
Google Translate API for unlimited and free translations
Install
go get github.com/bregydoc/gtranslate
Use
gtranslate.Translate("I'm alive", language.English, language.Spanish)
gtranslate.TranslateWithParams("I'm alive", gtranslate.TranslateWithParams{From: "en", To: "es"})
Example
package main
import (
"fmt"
"github.com/bregydoc/gtranslate"
)
func main() {
text := "Hello World"
translated, err := gtranslate.TranslateWithParams(
text,
gtranslate.TranslationParams{
From: "en",
To: "ja",
},
)
if err != nil {
panic(err)
}
fmt.Printf("en: %s | ja: %s \n", text, translated)
// en: Hello World | ja: γγγ«γ‘γ―δΈη
}