golang-AWS-SDK的翻译
需要引入的包
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/translate"
access_key:="xxxxxxxxx"
secret_key:="xxxxxxxxx"
translateSession = translate.New(session.Must(session.NewSession(&aws.Config{
Credentials: credentials.NewStaticCredentials(access_key, secret_key, ""),
Region: aws.String("xxxxxxx"), // Frankfurt
})))
response, err := translateSession.Text(&translate.TextInput{
SourceLanguageCode: aws.String(sourceLanguageCode),
TargetLanguageCode: aws.String(targetLanguageCode),
Text: aws.String(text),
})
if err != nil {
fmt.Println(err)
}
resultStr:=*response.TranslatedText
fmt.Println(resultStr)
参考文档
https://docs.aws.amazon.com/zh_cn/translate/latest/dg/what-is.html#language-pairs
有疑问加站长微信联系(非本文作者)