From 7cfc2d501f81ce1943645bba90644a9b50e82bc0 Mon Sep 17 00:00:00 2001 From: Alec Su Date: Mon, 10 Jul 2023 00:09:48 +0800 Subject: [PATCH] Retrieve full translated text Fix a bug when the translated text have multiple lines, only the first line is retrieved. --- api_v1.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api_v1.go b/api_v1.go index 3b4e323..322f3bf 100644 --- a/api_v1.go +++ b/api_v1.go @@ -223,7 +223,11 @@ func translateV1(text string, from string, to string) (*Translated, error) { txt := resp2[0].([]interface{})[0].(string) AutoCorrectedValue = &txt } - textTo := resp2[1].([]interface{})[0].([]interface{})[0].([]interface{})[5].([]interface{})[0].([]interface{})[0].(string) + textToBuilder := strings.Builder{} + for _, line := range resp2[1].([]interface{})[0].([]interface{})[0].([]interface{})[5].([]interface{}) { + textToBuilder.WriteString(line.([]interface{})[0].(string)) + } + textTo := textToBuilder.String() pronunciationfrom := resp2[1].([]interface{})[0].([]interface{})[0].([]interface{})[1] textIso := resp2[1].([]interface{})[3].(string) var pronunciation *string