|
@@ -260,6 +260,7 @@ func GetWeWorkUsersNickName() (err error) {
|
|
|
func DayNewTranslateContent() (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
+ utils.ApiLog.Println("企业微信 中翻英操作失败, Err:"+err.Error())
|
|
|
go alarm_msg.SendAlarmMsg("企业微信 中翻英操作失败, Err:"+err.Error(), 1)
|
|
|
}
|
|
|
}()
|
|
@@ -333,7 +334,11 @@ func DayNewTranslateContent() (err error) {
|
|
|
}
|
|
|
|
|
|
func batchTranslateHandler(contentMap map[string]string) (contentEnMap map[string]string, err error) {
|
|
|
- bytes,_ := json.Marshal(contentMap)
|
|
|
+ bytes, err := json.Marshal(contentMap)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("未翻译的内容json.Marshal失败"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
content := string(bytes)
|
|
|
en, err := AliTranslate(content)
|
|
|
if err != nil {
|
|
@@ -341,6 +346,10 @@ func batchTranslateHandler(contentMap map[string]string) (contentEnMap map[strin
|
|
|
}
|
|
|
//json转为map数据结构
|
|
|
err = json.Unmarshal([]byte(en), &contentEnMap)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("翻译后的内容json.Unmarshal失败"+err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
for k, v := range contentEnMap {
|
|
|
v = string([]byte(v)[:len(v)-3])
|
|
|
contentEnMap[k] = strings.ReplaceAll(v,`{quot}`, `"`)
|
|
@@ -349,7 +358,6 @@ func batchTranslateHandler(contentMap map[string]string) (contentEnMap map[strin
|
|
|
}
|
|
|
|
|
|
var punctuationMap = map[rune]rune{
|
|
|
- 12290: 46, // . //把。符号转换成.
|
|
|
8216: 34, // '
|
|
|
|
|
|
8217: 34, // '
|