google

package
v1.8.81 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: LGPL-3.0 Imports: 7 Imported by: 0

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 将文本从指定语言翻译为英文

Jump to

Keyboard shortcuts

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