translate

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaiduTransLangMap = map[string]string{
	"":       "auto",
	"自动":     "auto",
	"自动检测":   "auto",
	"中文":     "zh",
	"汉语":     "zh",
	"英语":     "en",
	"粤语":     "yue",
	"文言文":    "wyw",
	"日语":     "jp",
	"日文":     "jp",
	"韩语":     "kor",
	"韩文":     "kor",
	"法语":     "fra",
	"西语":     "spa",
	"西班牙语":   "spa",
	"泰语":     "th",
	"阿拉伯语":   "ara",
	"俄语":     "ru",
	"葡萄牙语":   "pt",
	"德语":     "de",
	"意大利语":   "it",
	"希腊语":    "el",
	"荷兰语":    "nl",
	"波兰语":    "pl",
	"保加利亚语":  "bul",
	"爱沙尼亚语":  "est",
	"丹麦语":    "dan",
	"芬兰语":    "fin",
	"捷克语":    "cs",
	"罗马尼亚语":  "rom",
	"斯洛文尼亚语": "slo",
	"瑞典语":    "swe",
	"匈牙利语":   "hu",
	"繁体":     "cht",
	"繁体中文":   "cht",
	"越南语":    "vie",
}

Functions

func BaiduCheckLangSupport

func BaiduCheckLangSupport(lang string, isFrom bool) (res string)

BaiduCheckLangSupport 检查该语种是否支持:若不支持,返回空字符串;若支持,返回纯小写字母语种代号

func BaiduTranslate

func BaiduTranslate(str, from, to string) (string, error)

BaiduTranslate 使用百度翻译API(每月超过200万字符收费)进行翻译

func FreeCheckLangSupport

func FreeCheckLangSupport(lang string) string

FreeCheckLangSupport 检查免费翻译是否支持该语种

func FreeTranslate

func FreeTranslate(str, from, to string) (string, error)

FreeTranslate 免费翻译

func Translate

func Translate(str, from, to string) (string, error)

Translate 通用翻译函数,from\to参数为纯小写,使用BaiduTransLangMap中的key或val,返回翻译结果,当err != nil时,返回的是错误原因

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL