Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 830 Bytes

README.md

File metadata and controls

46 lines (35 loc) · 830 Bytes

translate

Call Translate api to translate one or more characters

Installation

go get github.com/hwfy/translate

Example

package main

import (
	"github.com/hwfy/translate"
	"fmt"
)

func main() {
	query := "感谢"

	result := translate.Google("zh", "cht", query, "")
	fmt.Println(result)

	result = translate.Google("zh", "en", query, "")
	fmt.Println(result)

	result = translate.Google("zh", "jp", query, "")
	fmt.Println(result)

	querys := []string{"你好", "全球"}

	results := translate.Googles("zh", "cht", querys, "")
	fmt.Println(results)

	results = translate.Googles("zh", "en", querys, "")
	fmt.Println(results)

	results = translate.Googles("zh", "jp", querys, "")
	fmt.Println(results)
}
// OutPut:
// 感謝
// Thank
// ありがとうございます
// [你好 全球]
// [Hello. Global]
// [こんにちは グローバル]