mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-29 05:50:17 -07:00
fix: contextResults is nil
This commit is contained in:
parent
2a9c52bcb2
commit
40fe5397ab
@ -90,6 +90,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
|
||||
// translation
|
||||
translation += fmt.Sprintf("%v", data["translation"].([]interface{})[0])
|
||||
// definition and part of speech
|
||||
if data["contextResults"] != nil {
|
||||
for _, results := range data["contextResults"].(map[string]interface{})["results"].([]interface{}) {
|
||||
results := results.(map[string]interface{})
|
||||
// definition
|
||||
@ -108,6 +109,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
|
||||
}
|
||||
}
|
||||
definition = regexp.MustCompile("<(|/)em>").ReplaceAllString(definition, "")
|
||||
}
|
||||
|
||||
return translation, definition, partOfSpeech, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user