go mod tidy + gofmt

This commit is contained in:
Arya Kiran 2023-07-22 19:54:15 +05:30
parent e559ec9214
commit 9c2eaa6b99
No known key found for this signature in database
GPG key ID: 842D12BDA50DF120
14 changed files with 500 additions and 512 deletions

View file

@ -2,8 +2,8 @@ package cmd
import (
"codeberg.org/aryak/simplytranslate/utils"
"github.com/spf13/cobra"
"fmt"
"github.com/spf13/cobra"
)
var file string

View file

@ -2,8 +2,8 @@ package cmd
import (
"codeberg.org/aryak/simplytranslate/utils"
"github.com/spf13/cobra"
"fmt"
"github.com/spf13/cobra"
)
var engine string
@ -51,21 +51,9 @@ var translateCmd = &cobra.Command{
}
} else if engine == "yandex" {
if langlist == "sl" {
langList := utils.LangListYandex(langlist)
for _, num := range langList {
fmt.Println("List{")
fmt.Println(`Id: "`+num.Id+`",`)
fmt.Println(`Name: "`+num.Name+`",`)
fmt.Println("},")
}
fmt.Println(utils.LangListYandex(langlist))
} else if langlist == "tl" {
langList := utils.LangListYandex(langlist)
for _, num := range langList {
fmt.Println("List{")
fmt.Println(`Id: "`+num.Id+`",`)
fmt.Println(`Name: "`+num.Name+`",`)
fmt.Println("},")
}
fmt.Println(utils.LangListYandex(langlist))
} else {
fmt.Println(utils.TranslateYandex(dest, source, query))
}

4
go.mod
View file

@ -3,9 +3,11 @@ module codeberg.org/aryak/simplytranslate
go 1.20
require (
github.com/carlmjohnson/requests v0.23.4
github.com/gocolly/colly v1.2.0
github.com/gofiber/fiber/v2 v2.47.0
github.com/gofiber/template v1.8.0
github.com/google/go-querystring v1.1.0
github.com/joho/godotenv v1.5.1
github.com/otiai10/gosseract/v2 v2.4.0
github.com/spf13/cobra v1.7.0
@ -19,12 +21,10 @@ require (
github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.17 // indirect
github.com/antchfx/xpath v1.2.4 // indirect
github.com/carlmjohnson/requests v0.23.4 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect

16
go.sum
View file

@ -62,14 +62,11 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/antchfx/htmlquery v1.3.0 h1:5I5yNFOVI+egyia5F2s/5Do2nFWxJz41Tr3DyfKD25E=
github.com/antchfx/htmlquery v1.3.0/go.mod h1:zKPDVTMhfOmcwxheXUsx4rKJy8KEY/PU6eXr/2SebQ8=
github.com/antchfx/xmlquery v1.3.15 h1:aJConNMi1sMha5G8YJoAIF5P+H+qG1L73bSItWHo8Tw=
github.com/antchfx/xmlquery v1.3.15/go.mod h1:zMDv5tIGjOxY/JCNNinnle7V/EwthZ5IT8eeCGJKRWA=
github.com/antchfx/xmlquery v1.3.17 h1:d0qWjPp/D+vtRw7ivCwT5ApH/3CkQU8JOeo3245PpTk=
github.com/antchfx/xmlquery v1.3.17/go.mod h1:Afkq4JIeXut75taLSuI31ISJ/zeq+3jG7TunF7noreA=
github.com/antchfx/xpath v1.2.3/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
@ -149,7 +146,6 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
github.com/gocolly/colly v1.2.0 h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=
github.com/gocolly/colly v1.2.0/go.mod h1:Hof5T3ZswNVsOHYmba1u03W65HDWgpV5HifSuueE0EA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/fiber/v2 v2.43.0 h1:yit3E4kHf178B60p5CQBa/3v+WVuziWMa/G2ZNyLJB0=
github.com/gofiber/fiber/v2 v2.43.0/go.mod h1:mpS1ZNE5jU+u+BA4FbM+KKnUzJ4wzTK+FT2tG3tU+6I=
github.com/gofiber/fiber/v2 v2.47.0 h1:EN5lHVCc+Pyqh5OEsk8fzRiifgwpbrP0rulQ4iNf3fs=
github.com/gofiber/fiber/v2 v2.47.0/go.mod h1:mbFMVN1lQuzziTkkakgtKKdjfsXSw9BKR5lmcNksUoU=
@ -272,7 +268,6 @@ github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
@ -288,7 +283,6 @@ github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8Nz
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY=
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
@ -317,8 +311,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
@ -396,8 +388,6 @@ github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY52
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
@ -434,7 +424,6 @@ github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkC
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.45.0 h1:zPkkzpIn8tdHZUrVa6PzYd0i5verqiPSkgTd3bSUcpA=
github.com/valyala/fasthttp v1.45.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
github.com/valyala/fasthttp v1.48.0 h1:oJWvHb9BIZToTQS3MuQ2R3bJZiNSa2KiNdeI8A+79Tc=
github.com/valyala/fasthttp v1.48.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
@ -563,7 +552,6 @@ golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
@ -670,7 +658,6 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
@ -694,7 +681,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
@ -909,8 +895,6 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=

View file

@ -21,7 +21,6 @@ func HandleSourceLanguages(c *fiber.Ctx) error {
data = utils.LangListDeepl("sl")
} else if engine == "watson" {
data = utils.LangListWatson("sl")
}
} else if engine == "yandex" {
data = utils.LangListYandex("sl")
}
@ -43,7 +42,6 @@ func HandleTargetLanguages(c *fiber.Ctx) error {
data = utils.LangListDeepl("tl")
} else if engine == "watson" {
data = utils.LangListWatson("tl")
}
} else if engine == "yandex" {
data = utils.LangListYandex("tl")
}
@ -52,7 +50,7 @@ func HandleTargetLanguages(c *fiber.Ctx) error {
func HandleTTS(c *fiber.Ctx) error {
engine := c.Query("engine")
lang := c.Query("lang")
text := c.Query("text")
text := c.Query("text")
// Why does go not have an andor statement :(
if engine == "" {
return c.SendStatus(fiber.StatusBadRequest)
@ -67,6 +65,6 @@ func HandleTTS(c *fiber.Ctx) error {
} else if engine == "reverso" {
data = utils.TTSReverso(lang, text)
}
c.Set("Content-Type", "audio/mpeg")
c.Set("Content-Type", "audio/mpeg")
return c.Send([]byte(data))
}

View file

@ -1,20 +1,27 @@
package pages
import (
"os"
"runtime"
"codeberg.org/aryak/simplytranslate/utils"
"fmt"
"github.com/gofiber/fiber/v2"
"runtime"
)
func HandleIndex(c *fiber.Ctx) error {
// Check if all required queries are present
m := c.Queries()
sl, _ := m["sl"]
tl, _ := m["tl"]
engine, _ := m["engine"]
text, _ := m["text"]
if sl != "" && tl != "" && engine != "" && text != "" {
fmt.Println("Work")
}
return c.Render("index", fiber.Map{
"host": c.Hostname(),
"branch": utils.Branch,
"version": utils.Version(),
"fiberversion": fiber.Version,
"goversion": runtime.Version(),
"setupstatus": os.Getenv("SIMPLYTRANSLATE_SETUP_COMPLETE"),
})
}

View file

@ -47,8 +47,8 @@ func Serve(port string) {
}
link := strings.TrimPrefix(err.Error(), "Cannot GET ")
err = ctx.Status(code).Render("error", fiber.Map{
"error": err,
"link": link,
"error": err,
"link": link,
})
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")

View file

@ -17,14 +17,14 @@ func TranslateGoogle(to string, from string, text string) string {
answer = e.Text
})
type Options struct {
To string `url:"tl"`
UI string `url:"hl"`
From string `url:"sl"`
Text string `url:"q"`
To string `url:"tl"`
UI string `url:"hl"`
From string `url:"sl"`
Text string `url:"q"`
}
opt := Options{ to, to, from, text }
opt := Options{to, to, from, text}
v, _ := query.Values(opt)
url := "https://translate.google.com/m?"+v.Encode()
url := "https://translate.google.com/m?" + v.Encode()
sc.Visit(url)
return answer
}
@ -36,7 +36,7 @@ func TranslateReverso(to string, from string, query string) string {
return answer
}
func TranslateLibreTranslate(to string, from string, query string) string {
json := []byte(`{"q":"`+query+`","source":"`+from+`","target":"`+to+`"}`)
json := []byte(`{"q":"` + query + `","source":"` + from + `","target":"` + to + `"}`)
// TODO: Make it configurable
libreTranslateOut := PostRequest("https://translate.argosopentech.com/translate", json)
gjsonArr := libreTranslateOut.Get("translatedText").Array()
@ -44,24 +44,24 @@ func TranslateLibreTranslate(to string, from string, query string) string {
return answer
}
func TranslateWatson(to string, from string, query string) string {
json := []byte(`{"text":"`+query+`","source":"`+from+`","target":"`+to+`"}`)
watsonOut:= PostRequest("https://www.ibm.com/demos/live/watson-language-translator/api/translate/text", json)
json := []byte(`{"text":"` + query + `","source":"` + from + `","target":"` + to + `"}`)
watsonOut := PostRequest("https://www.ibm.com/demos/live/watson-language-translator/api/translate/text", json)
gjsonArr := watsonOut.Get("payload.translations.0.translation").Array()
answer := gjsonArr[0].String()
return answer
}
func TranslateYandex(to string, from string, text string) string {
type Options struct {
Translate string `url:"lang"`
Text string `url:"text"`
Srv string `url:"srv"`
Id string `url:"id"`
Reason string `url:"reason"`
Translate string `url:"lang"`
Text string `url:"text"`
Srv string `url:"srv"`
Id string `url:"id"`
Reason string `url:"reason"`
}
opt := Options{ from+"-"+to, text, "tr-mobile", "c2317111.64bac36a.ab16ef22.74722d6d6f62696c65-0-0", "submit"}
opt := Options{from + "-" + to, text, "tr-mobile", "c2317111.64bac36a.ab16ef22.74722d6d6f62696c65-0-0", "submit"}
v, _ := query.Values(opt)
yandexOut := GetRequest("https://translate.yandex.net/api/v1/tr.json/translate?"+v.Encode())
yandexOut := GetRequest("https://translate.yandex.net/api/v1/tr.json/translate?" + v.Encode())
gjsonArr := yandexOut.Get("text.0").Array()
answer := gjsonArr[0].String()
return answer

View file

@ -130,4 +130,3 @@ func LangListDeepl(listType string) []List {
}
return ListData
}

View file

@ -5,7 +5,6 @@ type List struct {
Id string
}
func LangListReverso(listType string) []List {
// IDs got from original simplytranslate-web and trial and error. Usually first three letters of language.
var ListData = []List{

View file

@ -2,414 +2,414 @@ package utils
func LangListYandex(listType string) []List {
var ListData = []List{
List{
Id: "af",
Name: "Afrikaans",
},
List{
Id: "sq",
Name: "Albanian",
},
List{
Id: "am",
Name: "Amharic",
},
List{
Id: "ar",
Name: "Arabic",
},
List{
Id: "hy",
Name: "Armenian",
},
List{
Id: "az",
Name: "Azerbaijani",
},
List{
Id: "ba",
Name: "Bashkir",
},
List{
Id: "eu",
Name: "Basque",
},
List{
Id: "be",
Name: "Belarusian",
},
List{
Id: "bn",
Name: "Bengali",
},
List{
Id: "bs",
Name: "Bosnian",
},
List{
Id: "bg",
Name: "Bulgarian",
},
List{
Id: "my",
Name: "Burmese",
},
List{
Id: "ca",
Name: "Catalan",
},
List{
Id: "ceb",
Name: "Cebuano",
},
List{
Id: "zh",
Name: "Chinese",
},
List{
Id: "cv",
Name: "Chuvash",
},
List{
Id: "hr",
Name: "Croatian",
},
List{
Id: "cs",
Name: "Czech",
},
List{
Id: "da",
Name: "Danish",
},
List{
Id: "nl",
Name: "Dutch",
},
List{
Id: "sjn",
Name: "Elvish (Sindarin)",
},
List{
Id: "emj",
Name: "Emoji",
},
List{
Id: "en",
Name: "English",
},
List{
Id: "eo",
Name: "Esperanto",
},
List{
Id: "et",
Name: "Estonian",
},
List{
Id: "fi",
Name: "Finnish",
},
List{
Id: "fr",
Name: "French",
},
List{
Id: "gl",
Name: "Galician",
},
List{
Id: "ka",
Name: "Georgian",
},
List{
Id: "de",
Name: "German",
},
List{
Id: "el",
Name: "Greek",
},
List{
Id: "gu",
Name: "Gujarati",
},
List{
Id: "ht",
Name: "Haitian",
},
List{
Id: "he",
Name: "Hebrew",
},
List{
Id: "mrj",
Name: "Hill Mari",
},
List{
Id: "hi",
Name: "Hindi",
},
List{
Id: "hu",
Name: "Hungarian",
},
List{
Id: "is",
Name: "Icelandic",
},
List{
Id: "id",
Name: "Indonesian",
},
List{
Id: "ga",
Name: "Irish",
},
List{
Id: "it",
Name: "Italian",
},
List{
Id: "ja",
Name: "Japanese",
},
List{
Id: "jv",
Name: "Javanese",
},
List{
Id: "kn",
Name: "Kannada",
},
List{
Id: "kazlat",
Name: "Kazakh (Latin)",
},
List{
Id: "kk",
Name: "Kazakh",
},
List{
Id: "km",
Name: "Khmer",
},
List{
Id: "ko",
Name: "Korean",
},
List{
Id: "ky",
Name: "Kyrgyz",
},
List{
Id: "lo",
Name: "Lao",
},
List{
Id: "la",
Name: "Latin",
},
List{
Id: "lv",
Name: "Latvian",
},
List{
Id: "lt",
Name: "Lithuanian",
},
List{
Id: "lb",
Name: "Luxembourgish",
},
List{
Id: "mk",
Name: "Macedonian",
},
List{
Id: "mg",
Name: "Malagasy",
},
List{
Id: "ms",
Name: "Malay",
},
List{
Id: "ml",
Name: "Malayalam",
},
List{
Id: "mt",
Name: "Maltese",
},
List{
Id: "mi",
Name: "Maori",
},
List{
Id: "mr",
Name: "Marathi",
},
List{
Id: "mhr",
Name: "Mari",
},
List{
Id: "mn",
Name: "Mongolian",
},
List{
Id: "ne",
Name: "Nepali",
},
List{
Id: "no",
Name: "Norwegian",
},
List{
Id: "pap",
Name: "Papiamento",
},
List{
Id: "fa",
Name: "Persian",
},
List{
Id: "pl",
Name: "Polish",
},
List{
Id: "pt-BR",
Name: "Portuguese (Brazilian)",
},
List{
Id: "pt",
Name: "Portuguese",
},
List{
Id: "pa",
Name: "Punjabi",
},
List{
Id: "ro",
Name: "Romanian",
},
List{
Id: "ru",
Name: "Russian",
},
List{
Id: "gd",
Name: "Scottish Gaelic",
},
List{
Id: "sr-Latn",
Name: "Serbian (Latin)",
},
List{
Id: "sr",
Name: "Serbian",
},
List{
Id: "si",
Name: "Sinhalese",
},
List{
Id: "sk",
Name: "Slovak",
},
List{
Id: "sl",
Name: "Slovenian",
},
List{
Id: "es",
Name: "Spanish",
},
List{
Id: "su",
Name: "Sundanese",
},
List{
Id: "sw",
Name: "Swahili",
},
List{
Id: "sv",
Name: "Swedish",
},
List{
Id: "tl",
Name: "Tagalog",
},
List{
Id: "tg",
Name: "Tajik",
},
List{
Id: "ta",
Name: "Tamil",
},
List{
Id: "tt",
Name: "Tatar",
},
List{
Id: "te",
Name: "Telugu",
},
List{
Id: "th",
Name: "Thai",
},
List{
Id: "tr",
Name: "Turkish",
},
List{
Id: "udm",
Name: "Udmurt",
},
List{
Id: "uk",
Name: "Ukrainian",
},
List{
Id: "ur",
Name: "Urdu",
},
List{
Id: "uzbcyr",
Name: "Uzbek (Cyrillic)",
},
List{
Id: "uz",
Name: "Uzbek",
},
List{
Id: "vi",
Name: "Vietnamese",
},
List{
Id: "cy",
Name: "Welsh",
},
List{
Id: "xh",
Name: "Xhosa",
},
List{
Id: "sah",
Name: "Yakut",
},
List{
Id: "yi",
Name: "Yiddish",
},
List{
Id: "zu",
Name: "Zulu",
},
List{
Id: "af",
Name: "Afrikaans",
},
List{
Id: "sq",
Name: "Albanian",
},
List{
Id: "am",
Name: "Amharic",
},
List{
Id: "ar",
Name: "Arabic",
},
List{
Id: "hy",
Name: "Armenian",
},
List{
Id: "az",
Name: "Azerbaijani",
},
List{
Id: "ba",
Name: "Bashkir",
},
List{
Id: "eu",
Name: "Basque",
},
List{
Id: "be",
Name: "Belarusian",
},
List{
Id: "bn",
Name: "Bengali",
},
List{
Id: "bs",
Name: "Bosnian",
},
List{
Id: "bg",
Name: "Bulgarian",
},
List{
Id: "my",
Name: "Burmese",
},
List{
Id: "ca",
Name: "Catalan",
},
List{
Id: "ceb",
Name: "Cebuano",
},
List{
Id: "zh",
Name: "Chinese",
},
List{
Id: "cv",
Name: "Chuvash",
},
List{
Id: "hr",
Name: "Croatian",
},
List{
Id: "cs",
Name: "Czech",
},
List{
Id: "da",
Name: "Danish",
},
List{
Id: "nl",
Name: "Dutch",
},
List{
Id: "sjn",
Name: "Elvish (Sindarin)",
},
List{
Id: "emj",
Name: "Emoji",
},
List{
Id: "en",
Name: "English",
},
List{
Id: "eo",
Name: "Esperanto",
},
List{
Id: "et",
Name: "Estonian",
},
List{
Id: "fi",
Name: "Finnish",
},
List{
Id: "fr",
Name: "French",
},
List{
Id: "gl",
Name: "Galician",
},
List{
Id: "ka",
Name: "Georgian",
},
List{
Id: "de",
Name: "German",
},
List{
Id: "el",
Name: "Greek",
},
List{
Id: "gu",
Name: "Gujarati",
},
List{
Id: "ht",
Name: "Haitian",
},
List{
Id: "he",
Name: "Hebrew",
},
List{
Id: "mrj",
Name: "Hill Mari",
},
List{
Id: "hi",
Name: "Hindi",
},
List{
Id: "hu",
Name: "Hungarian",
},
List{
Id: "is",
Name: "Icelandic",
},
List{
Id: "id",
Name: "Indonesian",
},
List{
Id: "ga",
Name: "Irish",
},
List{
Id: "it",
Name: "Italian",
},
List{
Id: "ja",
Name: "Japanese",
},
List{
Id: "jv",
Name: "Javanese",
},
List{
Id: "kn",
Name: "Kannada",
},
List{
Id: "kazlat",
Name: "Kazakh (Latin)",
},
List{
Id: "kk",
Name: "Kazakh",
},
List{
Id: "km",
Name: "Khmer",
},
List{
Id: "ko",
Name: "Korean",
},
List{
Id: "ky",
Name: "Kyrgyz",
},
List{
Id: "lo",
Name: "Lao",
},
List{
Id: "la",
Name: "Latin",
},
List{
Id: "lv",
Name: "Latvian",
},
List{
Id: "lt",
Name: "Lithuanian",
},
List{
Id: "lb",
Name: "Luxembourgish",
},
List{
Id: "mk",
Name: "Macedonian",
},
List{
Id: "mg",
Name: "Malagasy",
},
List{
Id: "ms",
Name: "Malay",
},
List{
Id: "ml",
Name: "Malayalam",
},
List{
Id: "mt",
Name: "Maltese",
},
List{
Id: "mi",
Name: "Maori",
},
List{
Id: "mr",
Name: "Marathi",
},
List{
Id: "mhr",
Name: "Mari",
},
List{
Id: "mn",
Name: "Mongolian",
},
List{
Id: "ne",
Name: "Nepali",
},
List{
Id: "no",
Name: "Norwegian",
},
List{
Id: "pap",
Name: "Papiamento",
},
List{
Id: "fa",
Name: "Persian",
},
List{
Id: "pl",
Name: "Polish",
},
List{
Id: "pt-BR",
Name: "Portuguese (Brazilian)",
},
List{
Id: "pt",
Name: "Portuguese",
},
List{
Id: "pa",
Name: "Punjabi",
},
List{
Id: "ro",
Name: "Romanian",
},
List{
Id: "ru",
Name: "Russian",
},
List{
Id: "gd",
Name: "Scottish Gaelic",
},
List{
Id: "sr-Latn",
Name: "Serbian (Latin)",
},
List{
Id: "sr",
Name: "Serbian",
},
List{
Id: "si",
Name: "Sinhalese",
},
List{
Id: "sk",
Name: "Slovak",
},
List{
Id: "sl",
Name: "Slovenian",
},
List{
Id: "es",
Name: "Spanish",
},
List{
Id: "su",
Name: "Sundanese",
},
List{
Id: "sw",
Name: "Swahili",
},
List{
Id: "sv",
Name: "Swedish",
},
List{
Id: "tl",
Name: "Tagalog",
},
List{
Id: "tg",
Name: "Tajik",
},
List{
Id: "ta",
Name: "Tamil",
},
List{
Id: "tt",
Name: "Tatar",
},
List{
Id: "te",
Name: "Telugu",
},
List{
Id: "th",
Name: "Thai",
},
List{
Id: "tr",
Name: "Turkish",
},
List{
Id: "udm",
Name: "Udmurt",
},
List{
Id: "uk",
Name: "Ukrainian",
},
List{
Id: "ur",
Name: "Urdu",
},
List{
Id: "uzbcyr",
Name: "Uzbek (Cyrillic)",
},
List{
Id: "uz",
Name: "Uzbek",
},
List{
Id: "vi",
Name: "Vietnamese",
},
List{
Id: "cy",
Name: "Welsh",
},
List{
Id: "xh",
Name: "Xhosa",
},
List{
Id: "sah",
Name: "Yakut",
},
List{
Id: "yi",
Name: "Yiddish",
},
List{
Id: "zu",
Name: "Zulu",
},
}
return ListData
}

View file

@ -10,7 +10,7 @@ package utils
// Name string
// Id string
//}
//// To get new language lists for google yandex and libertranslate.
//// To get new language lists for google yandex and libertranslate.
//func LangListGoogle(listType string) []List {
// UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
// if !ok {
@ -42,7 +42,7 @@ package utils
// for _, r := range gjsonArr {
// code := r.Get("code").String()
// name := r.Get("name").String()
//
//
// ListData = append(ListData, List{Id: code, Name: name})
// }
// if listType == "sl" {

View file

@ -1,29 +1,29 @@
package utils
import (
"context"
"encoding/base64"
"github.com/carlmjohnson/requests"
"github.com/google/go-querystring/query"
"os"
"context"
"encoding/base64"
)
type ReversoTTS struct {
Id string
Id string
Voice string
}
func TTSGoogle(lang string, text string) string {
type Options struct {
Lang string `url:"tl"`
Text string `url:"q"`
Client string `url:"client"`
Lang string `url:"tl"`
Text string `url:"q"`
Client string `url:"client"`
}
opt := Options{ lang, text, "tw-ob" }
opt := Options{lang, text, "tw-ob"}
v, _ := query.Values(opt)
var file string
url := "https://translate.google.com/translate_tts?"+v.Encode()
url := "https://translate.google.com/translate_tts?" + v.Encode()
err := requests.
URL(url).
ToString(&file).
@ -37,105 +37,105 @@ func TTSReverso(lang string, text string) string {
var TTSData = []ReversoTTS{
// http://voice.reverso.net/RestPronunciation.svc/v1/output=json/GetAvailableVoices with randomized deduplication
ReversoTTS{
Id: "ar",
Id: "ar",
Voice: "Mehdi22k",
},
ReversoTTS{
Id: "zh",
Id: "zh",
Voice: "Lulu22k",
},
ReversoTTS{
Id: "cz",
Id: "cz",
Voice: "Eliska22k",
},
ReversoTTS{
Id: "dk",
Id: "dk",
Voice: "Mette22k",
},
ReversoTTS{
Id: "nl",
Id: "nl",
Voice: "Daan22k",
},
ReversoTTS{
Id: "en",
Id: "en",
Voice: "Will22k",
},
ReversoTTS{
Id: "fr",
Id: "fr",
Voice: "Margaux22k",
},
ReversoTTS{
Id: "de",
Id: "de",
Voice: "Andreas22k",
},
ReversoTTS{
Id: "gr",
Id: "gr",
Voice: "Dimitris22k",
},
ReversoTTS{
Id: "heb",
Id: "heb",
Voice: "he-IL-Asaf",
},
ReversoTTS{
Id: "it",
Id: "it",
Voice: "Chiara22k",
},
ReversoTTS{
Id: "jp",
Id: "jp",
Voice: "Sakura22k",
},
ReversoTTS{
Id: "kr",
Id: "kr",
Voice: "Minji22k",
},
ReversoTTS{
Id: "pl",
Id: "pl",
Voice: "Monika22k",
},
ReversoTTS{
Id: "pt",
Id: "pt",
Voice: "Celia22k",
},
ReversoTTS{
Id: "ro",
Id: "ro",
Voice: "ro-RO-Andrei",
},
ReversoTTS{
Id: "ru",
Id: "ru",
Voice: "Alyona22k",
},
ReversoTTS{
Id: "es",
Id: "es",
Voice: "Antonio22k",
},
ReversoTTS{
Id: "se",
Id: "se",
Voice: "Erik22k",
},
ReversoTTS{
Id: "tr",
Id: "tr",
Voice: "Ipek22k",
},
}
// https://voice.reverso.net/RestPronunciation.svc/v1/output=json/GetVoiceStream/voiceName=Lulu22k?voiceSpeed=80&inputText=6K%20V6aqM Base64 input text
text2 := base64.StdEncoding.EncodeToString([]byte(text))
var voice string
for _, s := range TTSData {
if s.Id == lang {
voice = s.Voice
break
}
}
var voice string
for _, s := range TTSData {
if s.Id == lang {
voice = s.Voice
break
}
}
type Options struct {
VoiceSpeed int `url:"voiceSpeed"`
Text string `url:"inputText"`
VoiceSpeed int `url:"voiceSpeed"`
Text string `url:"inputText"`
}
opt := Options{ 80, text2 }
opt := Options{80, text2}
v, _ := query.Values(opt)
var file string
url := "https://voice.reverso.net/RestPronunciation.svc/v1/output=json/GetVoiceStream/voiceName="+voice+"?"+v.Encode()
url := "https://voice.reverso.net/RestPronunciation.svc/v1/output=json/GetVoiceStream/voiceName=" + voice + "?" + v.Encode()
UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
if !ok {

View file

@ -2,6 +2,19 @@
<main>
<h2>SimplyTranslate</h2>
<h3>Translate</h3>
<form action="/" method="get">
<label for="textin">Text To Translate:</label>
<textarea id="textin" name="textin" rows="4" cols="50"></textarea>
<input type="checkbox" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" name="vehicle3" value="Boat" checked>
<label for="vehicle3"> I have a boat</label><br><br>
<input type="submit" value="Submit">
</form>
<h3>Info</h3>
{{ if eq .version "unknown, please build with Go 1.13+ or use Git"}} SimplyTranslate
version: <code>unknown</code> {{ else }} SimplyTranslate version: