mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-30 06:20:20 -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
|
||||||
translation += fmt.Sprintf("%v", data["translation"].([]interface{})[0])
|
translation += fmt.Sprintf("%v", data["translation"].([]interface{})[0])
|
||||||
// definition and part of speech
|
// definition and part of speech
|
||||||
|
if data["contextResults"] != nil {
|
||||||
for _, results := range data["contextResults"].(map[string]interface{})["results"].([]interface{}) {
|
for _, results := range data["contextResults"].(map[string]interface{})["results"].([]interface{}) {
|
||||||
results := results.(map[string]interface{})
|
results := results.(map[string]interface{})
|
||||||
// definition
|
// definition
|
||||||
@ -108,6 +109,7 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
definition = regexp.MustCompile("<(|/)em>").ReplaceAllString(definition, "")
|
definition = regexp.MustCompile("<(|/)em>").ReplaceAllString(definition, "")
|
||||||
|
}
|
||||||
|
|
||||||
return translation, definition, partOfSpeech, nil
|
return translation, definition, partOfSpeech, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user