google-translate
google-translate copied to clipboard
A free and unlimited API for Google Translate Golang 💵 🚫
google-translate
A free and unlimited API for Google Translate
Parts of the code are ported from gtranslate and google-translate-api (also MIT license).
Features
- Auto language detection
- Spelling correction
- Language correction
- Fast and reliable – it uses the same servers that translate.google.com uses
Install
go get github.com/gilang-as/google-translate
API
Example
package main
import (
"encoding/json"
"fmt"
gtranslate "github.com/gilang-as/google-translate"
)
func main() {
value := gtranslate.Translate{
Text: "Halo Dunia",
//From: "id",
To: "en",
}
translated, err := gtranslate.Translator(value)
if err != nil {
panic(err)
}else{
prettyJSON, err := json.MarshalIndent(translated, "", "\t")
if err != nil {
panic(err)
}
fmt.Println(string(prettyJSON))
}
}
Returns an object:
text(string) – The translated text.pronunciation(string) – The Pronunciation text.from(object)language(object)did_you_mean(boolean) -trueif the API suggest a correction in the source languageiso(string) - The code of the language that the API has recognized in thetext
text(object)auto_corrected(boolean) –trueif the API has auto corrected thetextvalue(string) – The auto correctedtextor thetextwith suggested correctionsdid_you_mean(boolean) –trueif the API has suggested corrections to thetext
License
MIT © Gilang Adi S