Documentation ¶
Index ¶
- Constants
- Variables
- func BaiduTranslate(BaiduConfig *BaiduConfigType, from, to, text string) (result []string, fromLang string, err error)
- func DeeplTranslate(config *DeeplConfigType, from, to, text string) (result []string, fromLang string, err error)
- func GetYouDaoLang(lang, app string) (string, error)
- func GoogleTranslate(config *GoogleConfigType, from, to, text string) (result []string, fromLang string, err error)
- func InitTranslate()
- func SafeLangType(t, app string) (string, error)
- func YouDaoTranslate(YouDaoConfig *YouDaoConfigType, from, to, text string) (result []string, fromLang string, err error)
- type BaiduConfigType
- type DeeplConfigType
- type GoogleConfigType
- type TranslationResData
- type TranslationRespData
- type YouDaoConfigType
Constants ¶
View Source
const ( YouDao = "YouDao" Baidu = "Baidu" Google = "Google" Deepl = "Deepl" )
Variables ¶
View Source
var BasePlatformTranslateConf map[string][]map[string]*gvar.Var
BasePlatformTranslateConf 基础平台翻译配置
View Source
var BaseTranslateConf map[string]map[string]string
BaseTranslateConf 基础翻译配置
View Source
var InitPlatformConfFunc = initPlatformConfHandler
InitPlatformConfFunc 初始化平台配置
View Source
var InitTranslateBaseConf = func() map[string]map[string]string { translate := gfile.GetContents("./translate.json") if translate == "" { return nil } json, err := gjson.DecodeToJson(translate) if err != nil { return nil } m := make(map[string]map[string]string, 1) for s, v := range json.Var().MapStrVar() { m[s] = v.MapStrStr() } return m }
InitTranslateBaseConf 初始化翻译基础配置
Functions ¶
func BaiduTranslate ¶
func BaiduTranslate(BaiduConfig *BaiduConfigType, from, to, text string) (result []string, fromLang string, err error)
func DeeplTranslate ¶
func DeeplTranslate(config *DeeplConfigType, from, to, text string) (result []string, fromLang string, err error)
func GetYouDaoLang ¶
func GoogleTranslate ¶
func GoogleTranslate(config *GoogleConfigType, from, to, text string) (result []string, fromLang string, err error)
GoogleTranslate google 翻译
func InitTranslate ¶
func InitTranslate()
func SafeLangType ¶
func YouDaoTranslate ¶
func YouDaoTranslate(YouDaoConfig *YouDaoConfigType, from, to, text string) (result []string, fromLang string, err error)
YouDaoTranslate 有道翻译
Types ¶
type BaiduConfigType ¶
type BaiduConfigType struct { CurlTimeOut int `json:"curlTimeOut"` Url string `json:"url"` AppId string `json:"appId"` Key string `json:"key"` }
BaiduConfigType 百度的配置类型
type DeeplConfigType ¶
type DeeplConfigType struct { CurlTimeOut int `json:"curlTimeOut"` Url string `json:"url"` Key string `json:"key"` }
DeeplConfigType Deepl配置类型
type GoogleConfigType ¶
type GoogleConfigType struct { CurlTimeOut int `json:"curlTimeOut"` Url string `json:"url"` Key string `json:"key"` }
GoogleConfigType 谷歌配置类型
type TranslationResData ¶
type TranslationResData struct { From string `json:"from"` // 原文语言 To string `json:"to"` // 翻译后语言 Text string `json:"text"` // 原文 }
TranslationResData 翻译数据
type TranslationRespData ¶
type TranslationRespData struct { Result []string `json:"result"` // 翻译后内容 From string `json:"from"` // 实际原文语言 FromLen int `json:"fromLen"` // 翻译原文字数 ToLen []int `json:"toLen"` // 翻译后文字字数 To string `json:"to"` // 翻译后语言 Tool string `json:"tool"` // 翻译工具 }
func Translation ¶
func Translation(t *TranslationResData, cfg ...map[string][]map[string]*gvar.Var) (*TranslationRespData, error)
Translation 翻译
Click to show internal directories.
Click to hide internal directories.