You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
564 B
24 lines
564 B
package api
|
|
|
|
import (
|
|
"context"
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
"yunyan/sys/microsoft/translate"
|
|
)
|
|
|
|
// 翻译接口(后台管理用)
|
|
func (this *apiComp) Translate(session comm.IUserSession, req *pb.ApiTranslateReq) (resp *pb.ApiTranslateResp, errdata *pb.ErrorData) {
|
|
results, err := translate.Translate(context.Background(), req.From, req.To, req.Texts)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SystemError,
|
|
Message: "翻译失败: " + err.Error(),
|
|
}
|
|
return
|
|
}
|
|
resp = &pb.ApiTranslateResp{
|
|
Results: results,
|
|
}
|
|
return
|
|
}
|
|
|