谷歌翻译API

GitHub - bregydoc/gtranslate: Google translate API for unlimited and free translations, gtranslate generates the necessary token to use the Google Translate API for free

package main

import (
	"fmt"
	"os"

	"github.com/bregydoc/gtranslate"
)

func main() {
	os.Setenv("HTTPS_PROXY", "http://127.0.0.1:7890")

	text := "Hello World"
	translated, err := gtranslate.TranslateWithParams(
		text,
		gtranslate.TranslationParams{
			From: "en",
			To:   "cn",
		},
	)
	if err != nil {
		panic(err)
	}

	fmt.Printf("en: %s | ja: %s \n", text, translated)
	// en: Hello World | ja: こんにちは世界
}

猜你喜欢

转载自blog.csdn.net/SHELLCODE_8BIT/article/details/131903764