v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-27 21:11:11 -07:00

fix: ReversoTranslate with multi-line translation

This commit is contained in:
eeeXun 2023-03-27 16:39:01 +08:00
parent 854b569750
commit 62987e6c5e
2 changed files with 5 additions and 3 deletions

View File

@ -63,8 +63,8 @@ func (t *GoogleTranslate) Translate(message string) (translation, definition, pa
}
// translation = data[0]
for _, lines := range data[0].([]interface{}) {
translatedLine := lines.([]interface{})[0]
for _, line := range data[0].([]interface{}) {
translatedLine := line.([]interface{})[0]
translation += fmt.Sprintf("%v", translatedLine)
}
// part of speech = data[1]

View File

@ -83,7 +83,9 @@ func (t *ReversoTranslate) Translate(message string) (translation, definition, p
}
// translation
translation += fmt.Sprintf("%v", data["translation"].([]interface{})[0])
for _, line := range data["translation"].([]interface{}) {
translation += fmt.Sprintf("%v", line)
}
// definition and part of speech
if data["contextResults"] != nil {
for _, results := range data["contextResults"].(map[string]interface{})["results"].([]interface{}) {