Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResultData ¶
type ResultData struct { Data struct { Translations []struct { TranslatedText string `json:"translatedText"` } `json:"translations"` } `json:"data"` }
ResultData 用于解析翻译API的JSON响应
type TranslationService ¶
type TranslationService struct {
// contains filtered or unexported fields
}
TranslationService 包含用于Google翻译API的API密钥和主机信息
func NewTranslationService ¶
func NewTranslationService(apiKey, apiHost string) *TranslationService
NewTranslationService 初始化一个 TranslationService 实例,并设置 API 密钥和主机
func (*TranslationService) GoogleDetectLang ¶
func (g *TranslationService) GoogleDetectLang(text string) (string, error)
GoogleDetectLang 检测文本的语言
func (*TranslationService) GoogleTranslateToCN ¶
func (g *TranslationService) GoogleTranslateToCN(text string, source string) (string, error)
GoogleTranslateToCN 将文本从指定语言翻译为中文
func (*TranslationService) GoogleTranslateToEn ¶
func (g *TranslationService) GoogleTranslateToEn(text string, source string) (string, error)
GoogleTranslateToEn 将文本从指定语言翻译为英文
Click to show internal directories.
Click to hide internal directories.