This commit is contained in:
Arya 2023-08-15 14:56:57 +05:30
parent fa3612fbdf
commit bfd34a06f8
Signed by: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -1,13 +1,13 @@
package utils
import (
"github.com/gocolly/colly"
"strings"
"github.com/google/uuid"
"github.com/google/go-querystring/query"
"github.com/OwO-Network/gdeeplx"
"os"
"errors"
"github.com/OwO-Network/gdeeplx"
"github.com/gocolly/colly"
"github.com/google/go-querystring/query"
"github.com/google/uuid"
"os"
"strings"
)
type LangOut struct {
@ -171,7 +171,7 @@ func TranslateMyMemory(to string, from string, text string) (LangOut, error) {
Translate string `url:"langpair"`
Text string `url:"q"`
}
opt := Options{ from+"|"+to, text }
opt := Options{from + "|" + to, text}
v, _ := query.Values(opt)
myMemoryOut := GetRequest("https://api.mymemory.translated.net/get?" + v.Encode())
gjsonArr := myMemoryOut.Get("responseData.translatedText").Array()
@ -205,12 +205,12 @@ func TranslateYandex(to string, from string, text string) (LangOut, error) {
Srv string `url:"srv"`
Id string `url:"sid"`
}
uuidWithHyphen := uuid.New()
uuid := strings.Replace(uuidWithHyphen.String(), "-", "", -1)
opt := Options{from + "-" + to, text, "android", uuid+"-0-0"}
uuidWithHyphen := uuid.New()
uuid := strings.Replace(uuidWithHyphen.String(), "-", "", -1)
opt := Options{from + "-" + to, text, "android", uuid + "-0-0"}
v, _ := query.Values(opt)
yandexOut := PostRequest("https://translate.yandex.net/api/v1/tr.json/translate?" + v.Encode(), []byte(""))
yandexOut := PostRequest("https://translate.yandex.net/api/v1/tr.json/translate?"+v.Encode(), []byte(""))
gjsonArr := yandexOut.Get("text.0").Array()
var langout LangOut
langout.OutputText = gjsonArr[0].String()
@ -241,7 +241,7 @@ func TranslateDeepl(to string, from string, text string) (LangOut, error) {
return LangOut{}, errors.New("failed")
}
answer1 := answer.(map[string]interface{})
ans:= answer1["data"].(string)
ans := answer1["data"].(string)
var langout LangOut
langout.OutputText = ans
return langout, nil