v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-18 00:30:40 -07:00

fix: newline of message in argostranslate need to be replaced with \n

This commit is contained in:
eeeXun 2023-01-31 22:30:33 +08:00
parent 898ac53b97
commit 6b930d27f8

View File

@ -8,6 +8,7 @@ import (
"gtt/internal/lock"
"io/ioutil"
"net/http"
"strings"
)
const (
@ -61,7 +62,10 @@ func (t *ArgosTranslate) Translate(message string) (
bytes.NewBuffer([]byte(fmt.Sprintf(`{
"q": "%s",
"source": "%s",
"target": "%s" }`, message, langCode[t.srcLang], langCode[t.dstLang]))))
"target": "%s" }`,
strings.Replace(message, "\n", `\n`, -1),
langCode[t.srcLang],
langCode[t.dstLang]))))
if err != nil {
return "", "", "", err
}