update deps, make engine code into a lib
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 3m54s
mozhi pipeline / Build and publish artifacts (push) Successful in 13m27s

This commit is contained in:
Arya 2023-09-09 20:03:14 +05:30
parent 662192ab41
commit 566eb69743
Signed by: arya
GPG Key ID: 842D12BDA50DF120
28 changed files with 91 additions and 3537 deletions

View File

@ -40,8 +40,7 @@ jobs:
- name: Build mozhi - name: Build mozhi
run: | run: |
go mod download go mod download
go install github.com/swaggo/swag/cmd/swag@latest go run github.com/swaggo/swag/cmd/swag@latest init --parseDependency
swag init
GOOS=linux GOARCH=amd64 go build -o mozhi-linux-amd64 GOOS=linux GOARCH=amd64 go build -o mozhi-linux-amd64
GOOS=linux GOARCH=arm64 go build -o mozhi-linux-arm64 GOOS=linux GOARCH=arm64 go build -o mozhi-linux-arm64
GOOS=windows GOARCH=amd64 go build -o mozhi-windows-amd64.exe GOOS=windows GOARCH=amd64 go build -o mozhi-windows-amd64.exe

View File

@ -7,8 +7,7 @@ RUN apk --no-cache add git ca-certificates
COPY . . COPY . .
RUN go mod download RUN go mod download
RUN go install github.com/swaggo/swag/cmd/swag@latest RUN go run github.com/swaggo/swag/cmd/swag@latest init --parseDependency
RUN swag init
RUN GOOS=linux GOARCH=$TARGETARCH go build -o /src/mozhi RUN GOOS=linux GOARCH=$TARGETARCH go build -o /src/mozhi
FROM alpine:3.16 as bin FROM alpine:3.16 as bin

View File

@ -26,13 +26,16 @@ I'm initially focusing on the api and engines, but eventually Mozhi will have a
- MyMemory - MyMemory
- DuckDuckGo (almost 1-1 with Bing Translate) - DuckDuckGo (almost 1-1 with Bing Translate)
## Where is the engine code?
The engine code has recently been split from the main codebase. Please check [aryak/libmozhi](https://codeberg.org/aryak/libmozhi) for it.
## Installing ## Installing
You can either use [docker](https://codeberg.org/aryak/mozhi/src/branch/master/compose.yml) or the build artifacts from [CI jobs on git.projectsegfau.lt](https://git.projectsegfau.lt/arya/mozhi/actions). You can either use [docker](https://codeberg.org/aryak/mozhi/src/branch/master/compose.yml) or the build artifacts from [CI jobs on git.projectsegfau.lt](https://git.projectsegfau.lt/arya/mozhi/actions).
## Building ## Building
``` ```
go mod download go mod download
go run github.com/swaggo/swag/cmd/swag@latest init go run github.com/swaggo/swag/cmd/swag@latest init --parseDependency
go build -o mozhi go build -o mozhi
``` ```

View File

@ -3,7 +3,7 @@ package cmd
import ( import (
"fmt" "fmt"
"codeberg.org/aryak/mozhi/utils" libmozhi "codeberg.org/aryak/libmozhi"
"github.com/ktr0731/go-fuzzyfinder" "github.com/ktr0731/go-fuzzyfinder"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -20,7 +20,7 @@ var langlistCmd = &cobra.Command{
Use: "langlist", Use: "langlist",
Short: "List/select languages supported by an engine.", Short: "List/select languages supported by an engine.",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
list, err := utils.LangList(engineused, listtype) list, err := libmozhi.LangList(engineused, listtype)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {

View File

@ -4,7 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"codeberg.org/aryak/mozhi/utils" libmozhi "codeberg.org/aryak/libmozhi"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -22,7 +22,7 @@ var translateCmd = &cobra.Command{
Short: "Translate.", Short: "Translate.",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if engine == "all" { if engine == "all" {
data := utils.TranslateAll(dest, source, query) data := libmozhi.TranslateAll(dest, source, query)
if rawjson { if rawjson {
j, err := json.Marshal(data) j, err := json.Marshal(data)
if err != nil { if err != nil {
@ -44,7 +44,7 @@ var translateCmd = &cobra.Command{
fmt.Println("-----------------------------------") fmt.Println("-----------------------------------")
} }
} else { } else {
data, err := utils.Translate(engine, dest, source, query) data, err := libmozhi.Translate(engine, dest, source, query)
if rawjson { if rawjson {
j, err := json.Marshal(data) j, err := json.Marshal(data)
if err != nil { if err != nil {

View File

@ -1,5 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT. // Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs package docs
import "github.com/swaggo/swag" import "github.com/swaggo/swag"
@ -30,7 +29,7 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/utils.List"
} }
@ -52,7 +51,7 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/utils.List"
} }
@ -62,7 +61,7 @@ const docTemplate = `{
}, },
"/api/translate": { "/api/translate": {
"get": { "get": {
"description": "When engine is set to all, it will return an array of utils.LangOut.", "description": "When engine is set to all, it will return an array of libmozhi.LangOut.",
"summary": "Translate text", "summary": "Translate text",
"parameters": [ "parameters": [
{ {
@ -96,7 +95,7 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.LangOut" "$ref": "#/definitions/utils.LangOut"
} }

View File

@ -18,7 +18,7 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/utils.List"
} }
@ -40,7 +40,7 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/utils.List"
} }
@ -50,7 +50,7 @@
}, },
"/api/translate": { "/api/translate": {
"get": { "get": {
"description": "When engine is set to all, it will return an array of utils.LangOut.", "description": "When engine is set to all, it will return an array of libmozhi.LangOut.",
"summary": "Translate text", "summary": "Translate text",
"parameters": [ "parameters": [
{ {
@ -84,7 +84,7 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "success",
"schema": { "schema": {
"$ref": "#/definitions/utils.LangOut" "$ref": "#/definitions/utils.LangOut"
} }

View File

@ -32,7 +32,7 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: OK description: success
schema: schema:
$ref: '#/definitions/utils.List' $ref: '#/definitions/utils.List'
summary: Show list of available source languages for engine summary: Show list of available source languages for engine
@ -46,13 +46,13 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: OK description: success
schema: schema:
$ref: '#/definitions/utils.List' $ref: '#/definitions/utils.List'
summary: Show list of available target languages for engine summary: Show list of available target languages for engine
/api/translate: /api/translate:
get: get:
description: When engine is set to all, it will return an array of utils.LangOut. description: When engine is set to all, it will return an array of libmozhi.LangOut.
parameters: parameters:
- description: Engine name - description: Engine name
in: query in: query
@ -76,7 +76,7 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: OK description: success
schema: schema:
$ref: '#/definitions/utils.LangOut' $ref: '#/definitions/utils.LangOut'
summary: Translate text summary: Translate text

37
go.mod
View File

@ -1,27 +1,23 @@
module codeberg.org/aryak/mozhi module codeberg.org/aryak/mozhi
go 1.20 go 1.21.0
replace github.com/OwO-Network/gdeeplx => github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51 replace github.com/OwO-Network/gdeeplx => github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51
require ( require (
github.com/OwO-Network/gdeeplx v0.0.1 codeberg.org/aryak/libmozhi v0.0.0-20230909133311-5b21e2215c4c
github.com/carlmjohnson/requests v0.23.4 github.com/gofiber/fiber/v2 v2.49.1
github.com/gocolly/colly v1.2.0 github.com/gofiber/swagger v0.1.13
github.com/gofiber/fiber/v2 v2.49.0
github.com/gofiber/swagger v0.1.12
github.com/gofiber/template v1.8.0 github.com/gofiber/template v1.8.0
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.3.1
github.com/joho/godotenv v1.5.1 github.com/joho/godotenv v1.5.1
github.com/ktr0731/go-fuzzyfinder v0.7.0 github.com/ktr0731/go-fuzzyfinder v0.7.0
github.com/spf13/cobra v1.7.0 github.com/spf13/cobra v1.7.0
github.com/swaggo/swag v1.16.1 github.com/swaggo/swag v1.16.2
github.com/tidwall/gjson v1.14.4
) )
require ( require (
github.com/KyleBanks/depth v1.2.1 // indirect github.com/KyleBanks/depth v1.2.1 // indirect
github.com/OwO-Network/gdeeplx v0.0.1 // indirect
github.com/PuerkitoBio/goquery v1.8.1 // indirect github.com/PuerkitoBio/goquery v1.8.1 // indirect
github.com/abadojack/whatlanggo v1.0.1 // indirect github.com/abadojack/whatlanggo v1.0.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect github.com/andybalholm/brotli v1.0.5 // indirect
@ -29,15 +25,19 @@ require (
github.com/antchfx/htmlquery v1.3.0 // indirect github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.17 // indirect github.com/antchfx/xmlquery v1.3.17 // indirect
github.com/antchfx/xpath v1.2.4 // indirect github.com/antchfx/xpath v1.2.4 // indirect
github.com/carlmjohnson/requests v0.23.4 // indirect
github.com/gdamore/encoding v1.0.0 // indirect github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.5.3 // indirect github.com/gdamore/tcell/v2 v2.6.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect github.com/go-openapi/swag v0.22.4 // indirect
github.com/gobwas/glob v0.2.3 // indirect github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect github.com/kennygrant/sanitize v1.2.4 // indirect
@ -56,17 +56,18 @@ require (
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect github.com/temoto/robotstxt v1.1.2 // indirect
github.com/tidwall/gjson v1.16.0 // indirect
github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.48.0 // indirect github.com/valyala/fasthttp v1.49.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/net v0.14.0 // indirect golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.11.0 // indirect golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.11.0 // indirect golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.0 // indirect golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

39
go.sum
View File

@ -45,6 +45,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
codeberg.org/aryak/libmozhi v0.0.0-20230909133311-5b21e2215c4c h1:lnG0+NunYw4x6TUl00MQvucNTypqK6skms9MsKx0P2E=
codeberg.org/aryak/libmozhi v0.0.0-20230909133311-5b21e2215c4c/go.mod h1:DOxFxtSCKbs3sfKLxDwho9RFqkZy1opa67/c9v+/G+I=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
@ -68,6 +70,7 @@ 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/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 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= 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.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= 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/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
@ -143,6 +146,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.5.3 h1:b9XQrT6QGbgI7JvZOJXFNczOQeIYbo8BfeSMzt2sAV0= github.com/gdamore/tcell/v2 v2.5.3 h1:b9XQrT6QGbgI7JvZOJXFNczOQeIYbo8BfeSMzt2sAV0=
github.com/gdamore/tcell/v2 v2.5.3/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo= github.com/gdamore/tcell/v2 v2.5.3/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo=
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51 h1:UsBBzLOcgAHzumecyEwnwlvF/cfxizNJvVilj9zbQMc= github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51 h1:UsBBzLOcgAHzumecyEwnwlvF/cfxizNJvVilj9zbQMc=
github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51/go.mod h1:xLqaj0n6E2VmiI1RXBOFy8wLoiOurvO3O6QxUvepyVo= github.com/gi-yt/gdeeplx v0.0.0-20230817133036-0eb71706cd51/go.mod h1:xLqaj0n6E2VmiI1RXBOFy8wLoiOurvO3O6QxUvepyVo=
@ -180,8 +185,12 @@ github.com/gofiber/fiber/v2 v2.43.0/go.mod h1:mpS1ZNE5jU+u+BA4FbM+KKnUzJ4wzTK+FT
github.com/gofiber/fiber/v2 v2.46.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc= github.com/gofiber/fiber/v2 v2.46.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc=
github.com/gofiber/fiber/v2 v2.49.0 h1:xBVG2c66GDcWfww56xHvMn52Q0XX7UrSvjj6MD8/5EE= github.com/gofiber/fiber/v2 v2.49.0 h1:xBVG2c66GDcWfww56xHvMn52Q0XX7UrSvjj6MD8/5EE=
github.com/gofiber/fiber/v2 v2.49.0/go.mod h1:oxpt7wQaEYgdDmq7nMxCGhilYicBLFnZ+jQSJcQDlSE= github.com/gofiber/fiber/v2 v2.49.0/go.mod h1:oxpt7wQaEYgdDmq7nMxCGhilYicBLFnZ+jQSJcQDlSE=
github.com/gofiber/fiber/v2 v2.49.1 h1:0W2DRWevSirc8pJl4o8r8QejDR8TV6ZUCawHxwbIdOk=
github.com/gofiber/fiber/v2 v2.49.1/go.mod h1:nPUeEBUeeYGgwbDm59Gp7vS8MDyScL6ezr/Np9A13WU=
github.com/gofiber/swagger v0.1.12 h1:1Son/Nc1teiIftsVu6UHqXnJ3uf31pUzZO6XQDx3QYs= github.com/gofiber/swagger v0.1.12 h1:1Son/Nc1teiIftsVu6UHqXnJ3uf31pUzZO6XQDx3QYs=
github.com/gofiber/swagger v0.1.12/go.mod h1:iOCNEt1gNTtlvCEKoxYX4agnZNtxlAjhujMKG6pmG74= github.com/gofiber/swagger v0.1.12/go.mod h1:iOCNEt1gNTtlvCEKoxYX4agnZNtxlAjhujMKG6pmG74=
github.com/gofiber/swagger v0.1.13 h1:e7tMH/y34HIMklQ2+uv64Ai3E8TWCgbZyscIx+IzInE=
github.com/gofiber/swagger v0.1.13/go.mod h1:VtNHZdI5ksFlIR1R0vCcCX3/ruT8p9xNRX44958rsao=
github.com/gofiber/template v1.8.0 h1:jOn9RhxYO7rHTHGLNRpYfDoVm8b5GH/dtl15ZT5NifE= github.com/gofiber/template v1.8.0 h1:jOn9RhxYO7rHTHGLNRpYfDoVm8b5GH/dtl15ZT5NifE=
github.com/gofiber/template v1.8.0/go.mod h1:jf2w+ioGUS5swf5C/VK+FyE+DI19uz+vXHCX/TIAxIk= github.com/gofiber/template v1.8.0/go.mod h1:jf2w+ioGUS5swf5C/VK+FyE+DI19uz+vXHCX/TIAxIk=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@ -217,6 +226,7 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
@ -331,6 +341,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@ -419,6 +430,7 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
@ -463,17 +475,21 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw=
github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM=
github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg=
github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto=
github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg=
github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
@ -487,6 +503,8 @@ github.com/valyala/fasthttp v1.45.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE
github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasthttp v1.47.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 h1:oJWvHb9BIZToTQS3MuQ2R3bJZiNSa2KiNdeI8A+79Tc=
github.com/valyala/fasthttp v1.48.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasthttp v1.48.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
github.com/valyala/fasthttp v1.49.0 h1:9FdvCpmxB74LH4dPb7IJ1cOSsluR07XG3I1txXWwJpE=
github.com/valyala/fasthttp v1.49.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0= github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0=
@ -565,6 +583,7 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -619,6 +638,8 @@ 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.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -729,6 +750,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -740,6 +763,8 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -749,6 +774,7 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 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.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
@ -757,6 +783,8 @@ 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.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -822,6 +850,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -864,8 +894,9 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@ -969,6 +1000,7 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 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.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
@ -993,6 +1025,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -2,6 +2,7 @@ package pages
import ( import (
"codeberg.org/aryak/mozhi/utils" "codeberg.org/aryak/mozhi/utils"
libmozhi "codeberg.org/aryak/libmozhi"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )
@ -9,14 +10,14 @@ import (
// //
// @Summary Show list of available source languages for engine // @Summary Show list of available source languages for engine
// @Param engine query string true "Engine name" // @Param engine query string true "Engine name"
// @Success 200 {object} utils.List // @Success 200 {object} libmozhi.List
// @Router /api/source_languages [get] // @Router /api/source_languages [get]
func HandleSourceLanguages(c *fiber.Ctx) error { func HandleSourceLanguages(c *fiber.Ctx) error {
engine := utils.Sanitize(c.Query("engine"), "alpha") engine := utils.Sanitize(c.Query("engine"), "alpha")
if engine == "" { if engine == "" {
return fiber.NewError(fiber.StatusBadRequest, "engine is a required query string.") return fiber.NewError(fiber.StatusBadRequest, "engine is a required query string.")
} }
data, err := utils.LangList(engine, "sl") data, err := libmozhi.LangList(engine, "sl")
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }
@ -27,14 +28,14 @@ func HandleSourceLanguages(c *fiber.Ctx) error {
// //
// @Summary Show list of available target languages for engine // @Summary Show list of available target languages for engine
// @Param engine query string true "Engine name" // @Param engine query string true "Engine name"
// @Success 200 {object} utils.List // @Success 200 {object} libmozhi.List
// @Router /api/target_languages [get] // @Router /api/target_languages [get]
func HandleTargetLanguages(c *fiber.Ctx) error { func HandleTargetLanguages(c *fiber.Ctx) error {
engine := utils.Sanitize(c.Query("engine"), "alpha") engine := utils.Sanitize(c.Query("engine"), "alpha")
if engine == "" { if engine == "" {
return fiber.NewError(fiber.StatusBadRequest, "engine is a required query string.") return fiber.NewError(fiber.StatusBadRequest, "engine is a required query string.")
} }
data, err := utils.LangList(engine, "tl") data, err := libmozhi.LangList(engine, "tl")
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }
@ -55,7 +56,7 @@ func HandleTTS(c *fiber.Ctx) error {
if engine == "" || text == "" || lang == "" { if engine == "" || text == "" || lang == "" {
return fiber.NewError(fiber.StatusBadRequest, "engine, lang, text are required query strings.") return fiber.NewError(fiber.StatusBadRequest, "engine, lang, text are required query strings.")
} }
data, err := utils.TTS(engine, lang, text) data, err := libmozhi.TTS(engine, lang, text)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }
@ -66,12 +67,12 @@ func HandleTTS(c *fiber.Ctx) error {
// HandleTranslate godoc // HandleTranslate godoc
// //
// @Summary Translate text // @Summary Translate text
// @Description When engine is set to all, it will return an array of utils.LangOut. // @Description When engine is set to all, it will return an array of libmozhi.LangOut.
// @Param engine query string true "Engine name" // @Param engine query string true "Engine name"
// @Param from query string true "Source language" // @Param from query string true "Source language"
// @Param to query string true "Target language" // @Param to query string true "Target language"
// @Param text query string true "Text being translated" // @Param text query string true "Text being translated"
// @Success 200 {object} utils.LangOut // @Success 200 {object} libmozhi.LangOut
// @Router /api/translate [get] // @Router /api/translate [get]
func HandleTranslate(c *fiber.Ctx) error { func HandleTranslate(c *fiber.Ctx) error {
engine := utils.Sanitize(c.Query("engine"), "alpha") engine := utils.Sanitize(c.Query("engine"), "alpha")
@ -81,13 +82,13 @@ func HandleTranslate(c *fiber.Ctx) error {
if engine == "" || from == "" || to == "" || text == "" { if engine == "" || from == "" || to == "" || text == "" {
return fiber.NewError(fiber.StatusBadRequest, "from, to, engine, text are required query strings.") return fiber.NewError(fiber.StatusBadRequest, "from, to, engine, text are required query strings.")
} }
var dataarr []utils.LangOut var dataarr []libmozhi.LangOut
var data utils.LangOut var data libmozhi.LangOut
var err error var err error
if engine == "all" { if engine == "all" {
dataarr = utils.TranslateAll(to, from, text) dataarr = libmozhi.TranslateAll(to, from, text)
} else { } else {
data, err = utils.Translate(engine, to, from, text) data, err = libmozhi.Translate(engine, to, from, text)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }

View File

@ -4,8 +4,6 @@ import (
"fmt" "fmt"
"runtime" "runtime"
"codeberg.org/aryak/mozhi/utils"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )
@ -22,7 +20,6 @@ func HandleIndex(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{ return c.Render("index", fiber.Map{
"host": c.Hostname(), "host": c.Hostname(),
"version": utils.Version(),
"fiberversion": fiber.Version, "fiberversion": fiber.Version,
"goversion": runtime.Version(), "goversion": runtime.Version(),
}) })

View File

@ -8,8 +8,6 @@ import (
_ "codeberg.org/aryak/mozhi/docs" _ "codeberg.org/aryak/mozhi/docs"
"codeberg.org/aryak/mozhi/pages" "codeberg.org/aryak/mozhi/pages"
"codeberg.org/aryak/mozhi/utils"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress" "github.com/gofiber/fiber/v2/middleware/compress"
//"github.com/gofiber/fiber/v2/middleware/limiter" //"github.com/gofiber/fiber/v2/middleware/limiter"
@ -100,7 +98,6 @@ func Serve(port string) {
api.Get("/tts", pages.HandleTTS) api.Get("/tts", pages.HandleTTS)
api.Get("/version", func(c *fiber.Ctx) error { api.Get("/version", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"version": utils.Version(),
"fiberversion": fiber.Version, "fiberversion": fiber.Version,
"goversion": runtime.Version(), "goversion": runtime.Version(),
}) })

View File

@ -1,19 +0,0 @@
package utils
import "os"
func AutoDetectWatson(query string) (string, error) {
json := []byte(`{"text":"` + query + `"}`)
watsonOut := PostRequest("https://www.ibm.com/demos/live/watson-language-translator/api/translate/detect", json)
gjsonArr := watsonOut.Get("payload.languages.0.language.language").Array()
answer := gjsonArr[0].String()
return answer, nil
}
func AutoDetectLibreTranslate(query string) (string, error) {
json := []byte(`{"q":"` + query + `"}`)
libreTranslateOut := PostRequest(os.Getenv("MOZHI_LIBRETRANSLATE_URL")+"/detect", json)
gjsonArr := libreTranslateOut.Get("0.language").Array()
answer := gjsonArr[0].String()
return answer, nil
}

View File

@ -1,383 +0,0 @@
package utils
import (
"errors"
"io"
"net/http"
"os"
"regexp"
"strings"
"github.com/OwO-Network/gdeeplx"
"github.com/gocolly/colly"
"github.com/google/go-querystring/query"
"github.com/google/uuid"
)
var ddgVqd string
func TranslateGoogle(to string, from string, text string) (LangOut, error) {
ToOrig := to
FromOrig := from
// For some reason google uses no for norwegian instead of nb like the rest of the translators. This is for the All function primarily
if to == "nb" {
to = "no"
} else if from == "nb" {
to = "no"
}
var ToValid bool
var FromValid bool
for _, v := range LangListGoogle("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target Language Code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
if !ok {
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
}
sc := colly.NewCollector(colly.AllowedDomains("translate.google.com"), colly.UserAgent(UserAgent))
var answer string
sc.OnHTML("div.result-container", func(e *colly.HTMLElement) {
answer = e.Text
})
type Options struct {
To string `url:"tl"`
UI string `url:"hl"`
From string `url:"sl"`
Text string `url:"q"`
}
opt := Options{to, to, from, text}
v, _ := query.Values(opt)
url := "https://translate.google.com/m?" + v.Encode()
sc.Visit(url)
var langout LangOut
langout.OutputText = answer
langout.Engine = "google"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func TranslateReverso(to string, from string, query string) (LangOut, error) {
ToOrig := to
FromOrig := from
var ToValid bool
var FromValid bool
for _, v := range LangListReverso("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
json := []byte(`{ "format": "text", "from": "` + from + `", "to": "` + to + `", "input":"` + query + `", "options": {"sentenceSplitter": false, "origin":"translation.web", contextResults: false, languageDetection: true} }`)
reversoOut := PostRequest("https://api.reverso.net/translate/v1/translation", json)
gjsonArr := reversoOut.Get("translation").Array()
var langout LangOut
langout.OutputText = gjsonArr[0].String()
langout.Engine = "reverso"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func TranslateLibreTranslate(to string, from string, query string) (LangOut, error) {
ToOrig := to
FromOrig := from
var ToValid bool
var FromValid bool
for _, v := range LangListLibreTranslate("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
json := []byte(`{"q":"` + query + `","source":"` + from + `","target":"` + to + `"}`)
// TODO: Make it configurable
libreTranslateOut := PostRequest(os.Getenv("MOZHI_LIBRETRANSLATE_URL")+"/translate", json)
gjsonArr := libreTranslateOut.Get("translatedText").Array()
var langout LangOut
langout.OutputText = gjsonArr[0].String()
langout.Engine = "libretranslate"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
if from == "auto" {
langout.AutoDetect, _ = AutoDetectLibreTranslate(query)
}
return langout, nil
}
func TranslateWatson(to string, from string, query string) (LangOut, error) {
FromOrig := from
ToOrig := to
var ToValid bool
var FromValid bool
for _, v := range LangListWatson("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
var langout LangOut
if from == "auto" {
langout.AutoDetect, _ = AutoDetectWatson(query)
from = langout.AutoDetect
}
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()
langout.OutputText = gjsonArr[0].String()
langout.Engine = "watson"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func TranslateMyMemory(to string, from string, text string) (LangOut, error) {
FromOrig := from
ToOrig := to
var ToValid bool
var FromValid bool
for _, v := range LangListMyMemory("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
type Options struct {
Translate string `url:"langpair"`
Text string `url:"q"`
}
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()
var langout LangOut
langout.OutputText = gjsonArr[0].String()
langout.Engine = "mymemory"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func TranslateYandex(to string, from string, text string) (LangOut, error) {
FromOrig := from
ToOrig := to
var ToValid bool
var FromValid bool
for _, v := range LangListYandex("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
type Options struct {
Translate string `url:"lang"`
Text string `url:"text"`
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"}
v, _ := query.Values(opt)
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()
langout.Engine = "yandex"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func TranslateDeepl(to string, from string, text string) (LangOut, error) {
FromOrig := from
ToOrig := to
var ToValid bool
var FromValid bool
for _, v := range LangListDeepl("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
answer, err := gdeeplx.Translate(text, from, to, 0)
if err != nil {
return LangOut{}, errors.New("failed")
}
answer1 := answer.(map[string]interface{})
ans := answer1["data"].(string)
var langout LangOut
langout.OutputText = ans
langout.Engine = "deepl"
if from == "auto" {
langout.AutoDetect = strings.ToLower(answer1["detected_lang"].(string))
}
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
return langout, nil
}
func ddgVqdUpdate() {
r, err := http.NewRequest("GET", "https://duckduckgo.com/?q=translate", nil)
if err != nil {
panic(err)
}
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
if !ok {
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
}
r.Header.Set("User-Agent", UserAgent)
client := &http.Client{}
res, err := client.Do(r)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
re := regexp.MustCompile(`vqd="([^"]*)"`)
match := re.FindStringSubmatch(string(body))
ddgVqd = match[1]
}
func TranslateDuckDuckGo(to string, from string, query string) (LangOut, error) {
FromOrig := from
ToOrig := to
var ToValid bool
var FromValid bool
for _, v := range LangListDuckDuckGo("sl") {
if v.Id == to {
ToValid = true
}
if v.Id == from {
FromValid = true
}
if FromValid == true && ToValid == true {
break
}
}
if ToValid != true {
return LangOut{}, errors.New("Target language code invalid")
}
if FromValid != true {
return LangOut{}, errors.New("Source language code invalid")
}
var url string
var langout LangOut
ddgVqdUpdate()
if from == "auto" {
url = "https://duckduckgo.com/translation.js?vqd=" + ddgVqd + "&query=translate&to=" + to
} else {
url = "https://duckduckgo.com/translation.js?vqd=" + ddgVqd + "&query=translate&to=" + to + "&from=" + from
}
duckDuckGoOut := PostRequest(url, []byte(query))
gjsonArr := duckDuckGoOut.Get("translated").Array()
langout.OutputText = gjsonArr[0].String()
langout.Engine = "duckduckgo"
langout.SourceLang = FromOrig
langout.TargetLang = ToOrig
if from == "auto" {
langout.AutoDetect = duckDuckGoOut.Get("detected_language").String()
}
return langout, nil
}
func TranslateAll(to string, from string, query string) []LangOut {
engines := []string{"reverso", "google", "libre", "watson", "mymemory", "yandex", "deepl", "duckduckgo"}
langout := []LangOut{}
for i := 0; i < len(engines); i++ {
data, err := Translate(engines[i], to, from, query)
if err == nil {
langout = append(langout, data)
}
}
return langout
}

View File

@ -1,135 +0,0 @@
package utils
func LangListDeepl(listType string) []List {
// IDs got from deepl.com/translator
// Every time you change language, the # will get updated with the lang code.
ListData := []List{
{
Id: "bg",
Name: "Bulgarian",
},
{
Id: "zh",
Name: "Chinese (Simplified)",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "en",
Name: "English",
},
{
Id: "et",
Name: "Estonian",
},
{
Id: "fi",
Name: "Finnish",
},
{
Id: "fr",
Name: "French",
},
{
Id: "de",
Name: "Germany",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "lv",
Name: "Latvian",
},
{
Id: "lt",
Name: "Lithuanian",
},
{
Id: "nb",
Name: "Norwegian",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portugese",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "sl",
Name: "Slovenian",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "uk",
Name: "Ukrainian",
},
}
var ListD []List
if listType == "sl" {
auto := []List{{
Id: "auto",
Name: "Detect Language",
}}
ListD = append(append([]List{}, auto...), ListData...)
} else {
ListD = ListData
}
return ListD
}

View File

@ -1,531 +0,0 @@
package utils
func LangListDuckDuckGo(listType string) []List {
// DuckDuckGo is just Bing translate but easier to scrape :)
// Converted json of https://github.com/plainheart/bing-translate-api/blob/master/src/lang.json to this format
ListData := []List{
{
Id: "af",
Name: "Afrikaans",
},
{
Id: "sq",
Name: "Albanian",
},
{
Id: "am",
Name: "Amharic",
},
{
Id: "ar",
Name: "Arabic",
},
{
Id: "hy",
Name: "Armenian",
},
{
Id: "as",
Name: "Assamese",
},
{
Id: "az",
Name: "Azerbaijani",
},
{
Id: "bn",
Name: "Bangla",
},
{
Id: "ba",
Name: "Bashkir",
},
{
Id: "eu",
Name: "Basque",
},
{
Id: "bs",
Name: "Bosnian",
},
{
Id: "bg",
Name: "Bulgarian",
},
{
Id: "yue",
Name: "Cantonese (Traditional)",
},
{
Id: "ca",
Name: "Catalan",
},
{
Id: "lzh",
Name: "Chinese (Literary)",
},
{
Id: "zh-Hans",
Name: "Chinese Simplified",
},
{
Id: "zh-Hant",
Name: "Chinese Traditional",
},
{
Id: "hr",
Name: "Croatian",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "prs",
Name: "Dari",
},
{
Id: "dv",
Name: "Divehi",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "en",
Name: "English",
},
{
Id: "et",
Name: "Estonian",
},
{
Id: "fo",
Name: "Faroese",
},
{
Id: "fj",
Name: "Fijian",
},
{
Id: "fil",
Name: "Filipino",
},
{
Id: "fi",
Name: "Finnish",
},
{
Id: "fr",
Name: "French",
},
{
Id: "fr-CA",
Name: "French (Canada)",
},
{
Id: "gl",
Name: "Galician",
},
{
Id: "lug",
Name: "Ganda",
},
{
Id: "ka",
Name: "Georgian",
},
{
Id: "de",
Name: "German",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "gu",
Name: "Gujarati",
},
{
Id: "ht",
Name: "Haitian Creole",
},
{
Id: "ha",
Name: "Hausa",
},
{
Id: "he",
Name: "Hebrew",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "mww",
Name: "Hmong Daw",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "is",
Name: "Icelandic",
},
{
Id: "ig",
Name: "Igbo",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "ikt",
Name: "Inuinnaqtun",
},
{
Id: "iu",
Name: "Inuktitut",
},
{
Id: "iu-Latn",
Name: "Inuktitut (Latin)",
},
{
Id: "ga",
Name: "Irish",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "kn",
Name: "Kannada",
},
{
Id: "kk",
Name: "Kazakh",
},
{
Id: "km",
Name: "Khmer",
},
{
Id: "rw",
Name: "Kinyarwanda",
},
{
Id: "tlh-Latn",
Name: "Klingon (Latin)",
},
{
Id: "gom",
Name: "Konkani",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "ku",
Name: "Kurdish (Central)",
},
{
Id: "kmr",
Name: "Kurdish (Northern)",
},
{
Id: "ky",
Name: "Kyrgyz",
},
{
Id: "lo",
Name: "Lao",
},
{
Id: "lv",
Name: "Latvian",
},
{
Id: "ln",
Name: "Lingala",
},
{
Id: "lt",
Name: "Lithuanian",
},
{
Id: "dsb",
Name: "Lower Sorbian",
},
{
Id: "mk",
Name: "Macedonian",
},
{
Id: "mai",
Name: "Maithili",
},
{
Id: "mg",
Name: "Malagasy",
},
{
Id: "ms",
Name: "Malay",
},
{
Id: "ml",
Name: "Malayalam",
},
{
Id: "mt",
Name: "Maltese",
},
{
Id: "mr",
Name: "Marathi",
},
{
Id: "mn-Cyrl",
Name: "Mongolian (Cyrillic)",
},
{
Id: "mn-Mong",
Name: "Mongolian (Traditional)",
},
{
Id: "my",
Name: "Myanmar (Burmese)",
},
{
Id: "mi",
Name: "Māori",
},
{
Id: "ne",
Name: "Nepali",
},
{
Id: "nb",
Name: "Norwegian",
},
{
Id: "nya",
Name: "Nyanja",
},
{
Id: "or",
Name: "Odia",
},
{
Id: "ps",
Name: "Pashto",
},
{
Id: "fa",
Name: "Persian",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portuguese (Brazil)",
},
{
Id: "pt-PT",
Name: "Portuguese (Portugal)",
},
{
Id: "pa",
Name: "Punjabi",
},
{
Id: "otq",
Name: "Querétaro Otomi",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "run",
Name: "Rundi",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sm",
Name: "Samoan",
},
{
Id: "sr-Cyrl",
Name: "Serbian (Cyrillic)",
},
{
Id: "sr-Latn",
Name: "Serbian (Latin)",
},
{
Id: "st",
Name: "Sesotho",
},
{
Id: "nso",
Name: "Sesotho sa Leboa",
},
{
Id: "tn",
Name: "Setswana",
},
{
Id: "sn",
Name: "Shona",
},
{
Id: "sd",
Name: "Sindhi",
},
{
Id: "si",
Name: "Sinhala",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "sl",
Name: "Slovenian",
},
{
Id: "so",
Name: "Somali",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "sw",
Name: "Swahili",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "ty",
Name: "Tahitian",
},
{
Id: "ta",
Name: "Tamil",
},
{
Id: "tt",
Name: "Tatar",
},
{
Id: "te",
Name: "Telugu",
},
{
Id: "th",
Name: "Thai",
},
{
Id: "bo",
Name: "Tibetan",
},
{
Id: "ti",
Name: "Tigrinya",
},
{
Id: "to",
Name: "Tongan",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "tk",
Name: "Turkmen",
},
{
Id: "uk",
Name: "Ukrainian",
},
{
Id: "hsb",
Name: "Upper Sorbian",
},
{
Id: "ur",
Name: "Urdu",
},
{
Id: "ug",
Name: "Uyghur",
},
{
Id: "uz",
Name: "Uzbek (Latin)",
},
{
Id: "vi",
Name: "Vietnamese",
},
{
Id: "cy",
Name: "Welsh",
},
{
Id: "xh",
Name: "Xhosa",
},
{
Id: "yo",
Name: "Yoruba",
},
{
Id: "yua",
Name: "Yucatec Maya",
},
{
Id: "zu",
Name: "Zulu",
},
}
var ListD []List
if listType == "sl" {
auto := []List{{
Id: "auto",
Name: "Detect Language",
}}
ListD = append(append([]List{}, auto...), ListData...)
} else {
ListD = ListData
}
return ListD
}

View File

@ -1,550 +0,0 @@
package utils
func LangListGoogle(listType string) []List {
// IDs got from original simplytranslate-web and trial and error. Usually first three letters of language.
ListData := []List{
{
Id: "af",
Name: "Afrikaans",
},
{
Id: "sq",
Name: "Albanian",
},
{
Id: "am",
Name: "Amharic",
},
{
Id: "ar",
Name: "Arabic",
},
{
Id: "hy",
Name: "Armenian",
},
{
Id: "as",
Name: "Assamese",
},
{
Id: "ay",
Name: "Aymara",
},
{
Id: "az",
Name: "Azerbaijani",
},
{
Id: "bm",
Name: "Bambara",
},
{
Id: "eu",
Name: "Basque",
},
{
Id: "be",
Name: "Belarusian",
},
{
Id: "bn",
Name: "Bengali",
},
{
Id: "bho",
Name: "Bhojpuri",
},
{
Id: "bs",
Name: "Bosnian",
},
{
Id: "bg",
Name: "Bulgarian",
},
{
Id: "ca",
Name: "Catalan",
},
{
Id: "ceb",
Name: "Cebuano",
},
{
Id: "ny",
Name: "Chichewa",
},
{
Id: "zh",
Name: "Chinese (Simplified)",
},
{
Id: "zh-TW",
Name: "Chinese (Traditional)",
},
{
Id: "co",
Name: "Corsican",
},
{
Id: "hr",
Name: "Croatian",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "dv",
Name: "Dhivehi",
},
{
Id: "doi",
Name: "Dogri",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "en",
Name: "English",
},
{
Id: "eo",
Name: "Esperanto",
},
{
Id: "et",
Name: "Estonian",
},
{
Id: "ee",
Name: "Ewe",
},
{
Id: "tl",
Name: "Filipino",
},
{
Id: "fi",
Name: "Finnish",
},
{
Id: "fr",
Name: "French",
},
{
Id: "fy",
Name: "Frisian",
},
{
Id: "gl",
Name: "Galician",
},
{
Id: "ka",
Name: "Georgian",
},
{
Id: "de",
Name: "German",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "gn",
Name: "Guarani",
},
{
Id: "gu",
Name: "Gujarati",
},
{
Id: "ht",
Name: "Haitian Creole",
},
{
Id: "ha",
Name: "Hausa",
},
{
Id: "haw",
Name: "Hawaiian",
},
{
Id: "iw",
Name: "Hebrew",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "hmn",
Name: "Hmong",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "is",
Name: "Icelandic",
},
{
Id: "ig",
Name: "Igbo",
},
{
Id: "ilo",
Name: "Ilocano",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "ga",
Name: "Irish",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "jw",
Name: "Javanese",
},
{
Id: "kn",
Name: "Kannada",
},
{
Id: "kk",
Name: "Kazakh",
},
{
Id: "km",
Name: "Khmer",
},
{
Id: "rw",
Name: "Kinyarwanda",
},
{
Id: "gom",
Name: "Konkani",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "kri",
Name: "Krio",
},
{
Id: "ku",
Name: "Kurdish (Kurmanji)",
},
{
Id: "ckb",
Name: "Kurdish (Sorani)",
},
{
Id: "ky",
Name: "Kyrgyz",
},
{
Id: "lo",
Name: "Lao",
},
{
Id: "la",
Name: "Latin",
},
{
Id: "lv",
Name: "Latvian",
},
{
Id: "ln",
Name: "Lingala",
},
{
Id: "lt",
Name: "Lithuanian",
},
{
Id: "lg",
Name: "Luganda",
},
{
Id: "lb",
Name: "Luxembourgish",
},
{
Id: "mk",
Name: "Macedonian",
},
{
Id: "mai",
Name: "Maithili",
},
{
Id: "mg",
Name: "Malagasy",
},
{
Id: "ms",
Name: "Malay",
},
{
Id: "ml",
Name: "Malayalam",
},
{
Id: "mt",
Name: "Maltese",
},
{
Id: "mi",
Name: "Maori",
},
{
Id: "mr",
Name: "Marathi",
},
{
Id: "mni-Mtei",
Name: "Meiteilon (Manipuri)",
},
{
Id: "lus",
Name: "Mizo",
},
{
Id: "mn",
Name: "Mongolian",
},
{
Id: "my",
Name: "Myanmar (Burmese)",
},
{
Id: "ne",
Name: "Nepali",
},
{
Id: "no",
Name: "Norwegian",
},
{
Id: "or",
Name: "Odia (Oriya)",
},
{
Id: "om",
Name: "Oromo",
},
{
Id: "ps",
Name: "Pashto",
},
{
Id: "fa",
Name: "Persian",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portuguese",
},
{
Id: "pa",
Name: "Punjabi",
},
{
Id: "qu",
Name: "Quechua",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sm",
Name: "Samoan",
},
{
Id: "sa",
Name: "Sanskrit",
},
{
Id: "gd",
Name: "Scots Gaelic",
},
{
Id: "nso",
Name: "Sepedi",
},
{
Id: "sr",
Name: "Serbian",
},
{
Id: "st",
Name: "Sesotho",
},
{
Id: "sn",
Name: "Shona",
},
{
Id: "sd",
Name: "Sindhi",
},
{
Id: "si",
Name: "Sinhala",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "sl",
Name: "Slovenian",
},
{
Id: "so",
Name: "Somali",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "su",
Name: "Sundanese",
},
{
Id: "sw",
Name: "Swahili",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "tg",
Name: "Tajik",
},
{
Id: "ta",
Name: "Tamil",
},
{
Id: "tt",
Name: "Tatar",
},
{
Id: "te",
Name: "Telugu",
},
{
Id: "th",
Name: "Thai",
},
{
Id: "ti",
Name: "Tigrinya",
},
{
Id: "ts",
Name: "Tsonga",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "tk",
Name: "Turkmen",
},
{
Id: "ak",
Name: "Twi",
},
{
Id: "uk",
Name: "Ukrainian",
},
{
Id: "ur",
Name: "Urdu",
},
{
Id: "ug",
Name: "Uyghur",
},
{
Id: "uz",
Name: "Uzbek",
},
{
Id: "vi",
Name: "Vietnamese",
},
{
Id: "cy",
Name: "Welsh",
},
{
Id: "xh",
Name: "Xhosa",
},
{
Id: "yi",
Name: "Yiddish",
},
{
Id: "yo",
Name: "Yoruba",
},
{
Id: "zu",
Name: "Zulu",
},
}
var ListD []List
if listType == "sl" {
auto := []List{{
Id: "auto",
Name: "Detect Language",
}}
ListD = append(append([]List{}, auto...), ListData...)
} else {
ListD = ListData
}
return ListD
}

View File

@ -1,85 +0,0 @@
package utils
func LangListLibreTranslate(listType string) []List {
ListData := []List{
{
Id: "en",
Name: "English",
},
{
Id: "ar",
Name: "Arabic",
},
{
Id: "zh",
Name: "Chinese",
},
{
Id: "fr",
Name: "French",
},
{
Id: "de",
Name: "German",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "ga",
Name: "Irish",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portuguese",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "vi",
Name: "Vietnamese",
},
}
var ListD []List
if listType == "sl" {
auto := []List{{
Id: "auto",
Name: "Detect Language",
}}
ListD = append(append([]List{}, auto...), ListData...)
} else {
ListD = ListData
}
return ListD
}

View File

@ -1,563 +0,0 @@
package utils
func LangListMyMemory(listType string) []List {
ListData := []List{
{
Id: "af",
Name: "Afrikaans",
},
{
Id: "sq",
Name: "Albanian",
},
{
Id: "am",
Name: "Amharic",
},
{
Id: "ar",
Name: "Arabic",
},
{
Id: "hy",
Name: "Armenian",
},
{
Id: "az",
Name: "Azerbaijani",
},
{
Id: "bjs",
Name: "Bajan",
},
{
Id: "rm",
Name: "Balkan Gipsy",
},
{
Id: "eu",
Name: "Basque",
},
{
Id: "bem",
Name: "Bemba",
},
{
Id: "bn",
Name: "Bengali",
},
{
Id: "be",
Name: "Bielarus",
},
{
Id: "bi",
Name: "Bislama",
},
{
Id: "bs",
Name: "Bosnian",
},
{
Id: "br",
Name: "Breton",
},
{
Id: "bg",
Name: "Bulgarian",
},
{
Id: "my",
Name: "Burmese",
},
{
Id: "ca",
Name: "Catalan",
},
{
Id: "ceb",
Name: "Cebuano",
},
{
Id: "ch",
Name: "Chamorro",
},
{
Id: "zh",
Name: "Chinese (Simplified)",
},
{
Id: "zh-TW",
Name: "Chinese (Traditional)",
},
{
Id: "zdj",
Name: "Comorian",
},
{
Id: "cop",
Name: "Coptic",
},
{
Id: "hr",
Name: "Croatian",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "dz",
Name: "Dzongkha",
},
{
Id: "en",
Name: "English",
},
{
Id: "eo",
Name: "Esperanto",
},
{
Id: "et",
Name: "Estonian",
},
{
Id: "fnG",
Name: "Fanagalo",
},
{
Id: "fo",
Name: "Faroese",
},
{
Id: "fi",
Name: "Finnish",
},
{
Id: "fr",
Name: "French",
},
{
Id: "gl",
Name: "Galician",
},
{
Id: "ka",
Name: "Georgian",
},
{
Id: "de",
Name: "German",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "grc",
Name: "Greek (Classical)",
},
{
Id: "gu",
Name: "Gujarati",
},
{
Id: "ha",
Name: "Hausa",
},
{
Id: "haw",
Name: "Hawaiian",
},
{
Id: "he",
Name: "Hebrew",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "is",
Name: "Icelandic",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "kl",
Name: "Inuktitut (Greenland)",
},
{
Id: "ga",
Name: "Irish Gaelic",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "jv",
Name: "Javanese",
},
{
Id: "kea",
Name: "Kabuverdianu",
},
{
Id: "kab",
Name: "Kabylian",
},
{
Id: "kn",
Name: "Kannada",
},
{
Id: "kk",
Name: "Kazakh",
},
{
Id: "km",
Name: "Khmer",
},
{
Id: "rw",
Name: "Kinyarwanda",
},
{
Id: "rn",
Name: "Kirundi",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "ku",
Name: "Kurdish",
},
{
Id: "ckb",
Name: "Kurdish Sorani",
},
{
Id: "ky",
Name: "Kyrgyz",
},
{
Id: "lo",
Name: "Lao",
},
{
Id: "la",
Name: "Latin",
},
{
Id: "lv",
Name: "Latvian",
},
{
Id: "lt",
Name: "Lithuanian",
},
{
Id: "lb",
Name: "Luxembourgish",
},
{
Id: "mk",
Name: "Macedonian",
},
{
Id: "mg",
Name: "Malagasy",
},
{
Id: "ms",
Name: "Malay",
},
{
Id: "dv",
Name: "Maldivian",
},
{
Id: "mt",
Name: "Maltese",
},
{
Id: "gv",
Name: "Manx Gaelic",
},
{
Id: "mi",
Name: "Maori",
},
{
Id: "mh",
Name: "Marshallese",
},
{
Id: "men",
Name: "Mende",
},
{
Id: "mn",
Name: "Mongolian",
},
{
Id: "mfe",
Name: "Morisyen",
},
{
Id: "ne",
Name: "Nepali",
},
{
Id: "niu",
Name: "Niuean",
},
{
Id: "no",
Name: "Norwegian",
},
{
Id: "ny",
Name: "Nyanja",
},
{
Id: "ur",
Name: "Pakistani",
},
{
Id: "pau",
Name: "Palauan",
},
{
Id: "pa",
Name: "Panjabi",
},
{
Id: "pap",
Name: "Papiamentu",
},
{
Id: "ps",
Name: "Pashto",
},
{
Id: "fa",
Name: "Persian",
},
{
Id: "pis",
Name: "Pijin",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portuguese",
},
{
Id: "pot",
Name: "Potawatomi",
},
{
Id: "qu",
Name: "Quechua",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sm",
Name: "Samoan",
},
{
Id: "sg",
Name: "Sango",
},
{
Id: "gd",
Name: "Scots Gaelic",
},
{
Id: "sr",
Name: "Serbian",
},
{
Id: "sn",
Name: "Shona",
},
{
Id: "si",
Name: "Sinhala",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "sl",
Name: "Slovenian",
},
{
Id: "so",
Name: "Somali",
},
{
Id: "st",
Name: "Sotho Southern",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "srn",
Name: "Sranan Tongo",
},
{
Id: "sw",
Name: "Swahili",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "syc",
Name: "Syriac (Aramic)",
},
{
Id: "tl",
Name: "Tagalog",
},
{
Id: "tg",
Name: "Tajik",
},
{
Id: "tmh",
Name: "Tamashek (Tuareg)",
},
{
Id: "ta",
Name: "Tamil",
},
{
Id: "te",
Name: "Telugu",
},
{
Id: "tet",
Name: "Tetum",
},
{
Id: "th",
Name: "Thai",
},
{
Id: "bo",
Name: "Tibetan",
},
{
Id: "ti",
Name: "Tigrinya",
},
{
Id: "tpi",
Name: "Tok Pisin",
},
{
Id: "tkl",
Name: "Tokelauan",
},
{
Id: "to",
Name: "Tongan",
},
{
Id: "tn",
Name: "Tswana",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "tk",
Name: "Turkmen",
},
{
Id: "tvl",
Name: "Tuvaluan",
},
{
Id: "uk",
Name: "Ukrainian",
},
{
Id: "ppk",
Name: "Uma",
},
{
Id: "uz",
Name: "Uzbek",
},
{
Id: "vi",
Name: "Vietnamese",
},
{
Id: "wls",
Name: "Wallisian",
},
{
Id: "cy",
Name: "Welsh",
},
{
Id: "wo",
Name: "Wolof",
},
{
Id: "xh",
Name: "Xhosa",
},
{
Id: "yi",
Name: "Yiddish",
},
{
Id: "zu",
Name: "Zulu",
},
}
return ListData
}

View File

@ -1,112 +0,0 @@
package utils
func LangListReverso(listType string) []List {
// IDs got from original simplytranslate-web and trial and error. Usually first three letters of language.
ListData := []List{
{
Id: "ar",
Name: "Arabic",
},
{
Id: "zh",
Name: "Chinese (Simplified)",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "en",
Name: "English",
},
{
Id: "fr",
Name: "French",
},
{
Id: "de",
Name: "German",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "he",
Name: "Hebrew",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "per",
Name: "Persian",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portugese",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "th",
Name: "Thai",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "uk",
Name: "Ukrainian",
},
}
return ListData
}

View File

@ -1,246 +0,0 @@
package utils
func LangListWatson(listType string) []List {
// IDs got from https://www.loc.gov/standards/iso639-2/php/code_list.php and tested to make sure they work. Exceptions fr-CA zh-CN/TW
ListData := []List{
{
Id: "ar",
Name: "Arabic",
},
{
Id: "ba",
Name: "Basque",
},
{
Id: "bn",
Name: "Bengali",
},
{
Id: "bs",
Name: "Bosnian",
},
{
Id: "bg",
Name: "Bulgarian",
},
{
Id: "ca",
Name: "Catalan",
},
{
Id: "zh",
Name: "Chinese (Simplified)",
},
{
Id: "zh-TW",
Name: "Chinese (Traditional)",
},
{
Id: "hr",
Name: "Croatian",
},
{
Id: "cs",
Name: "Czech",
},
{
Id: "da",
Name: "Danish",
},
{
Id: "nl",
Name: "Dutch",
},
{
Id: "en",
Name: "English",
},
{
Id: "et",
Name: "Estonian",
},
{
Id: "fi",
Name: "Finnish",
},
{
Id: "fr",
Name: "French",
},
{
Id: "fr-CA",
Name: "Canadian French",
},
{
Id: "de",
Name: "German",
},
{
Id: "el",
Name: "Greek",
},
{
Id: "gu",
Name: "Gujarati",
},
{
Id: "he",
Name: "Hebrew",
},
{
Id: "hi",
Name: "Hindi",
},
{
Id: "hu",
Name: "Hungarian",
},
{
Id: "id",
Name: "Indonesian",
},
{
Id: "ga",
Name: "Irish",
},
{
Id: "it",
Name: "Italian",
},
{
Id: "ja",
Name: "Japanese",
},
{
Id: "kn",
Name: "Kannada",
},
{
Id: "ko",
Name: "Korean",
},
{
Id: "lv",
Name: "Latvian",
},
{
Id: "lt",
Name: "Lithuanian",
},
{
Id: "ms",
Name: "Malay",
},
{
Id: "ml",
Name: "Malayalam",
},
{
Id: "mt",
Name: "Maltese",
},
{
Id: "mr",
Name: "Marathi",
},
{
Id: "cnr",
Name: "Montenegrin",
},
{
Id: "ne",
Name: "Nepali",
},
{
Id: "nb",
Name: "Norwegian",
},
{
Id: "pl",
Name: "Polish",
},
{
Id: "pt",
Name: "Portugese",
},
{
Id: "pa",
Name: "Punjabi",
},
{
Id: "ro",
Name: "Romanian",
},
{
Id: "ru",
Name: "Russian",
},
{
Id: "sr",
Name: "Serbian",
},
{
Id: "si",
Name: "Sinhalese",
},
{
Id: "sk",
Name: "Slovak",
},
{
Id: "sl",
Name: "Slovenian",
},
{
Id: "es",
Name: "Spanish",
},
{
Id: "sv",
Name: "Swedish",
},
{
Id: "ta",
Name: "Tamil",
},
{
Id: "te",
Name: "Telugu",
},
{
Id: "th",
Name: "Thai",
},
{
Id: "tr",
Name: "Turkish",
},
{
Id: "uk",
Name: "Ukrainian",
},
{
Id: "ur",
Name: "Urdu",
},
{
Id: "vi",
Name: "Vietnamese",
},
{
Id: "cy",
Name: "Welsh",
},
}
var ListD []List
if listType == "sl" {
auto := []List{{
Id: "auto",
Name: "Detect Language",
}}
ListD = append(append([]List{}, auto...), ListData...)
} else {
ListD = ListData
}
return ListD
}

View File

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

View File

@ -1,103 +0,0 @@
package utils
import (
"errors"
"os"
)
type List struct {
Name string
Id string
}
type LangOut struct {
Engine string `json:"engine"`
AutoDetect string `json:"detected"`
OutputText string `json:"translated-text"`
SourceLang string `json:"source_language"`
TargetLang string `json:"target_language"`
}
func EnvTrueNoExist(env string) bool {
if _, ok := os.LookupEnv(env); ok == false || os.Getenv(env) == "true" {
return true
}
return false
}
func LangList(engine string, listType string) ([]List, error) {
var data []List
if listType != "sl" && listType != "tl" {
return []List{}, errors.New("list type invalid: either give tl for target languages or sl for source languages.")
}
if engine == "google" && EnvTrueNoExist("MOZHI_GOOGLE_ENABLED") {
data = LangListGoogle(listType)
} else if engine == "libre" && EnvTrueNoExist("MOZHI_LIBRETRANSLATE_ENABLED") {
if EnvTrueNoExist("MOZHI_LIBRETRANSLATE_URL") {
return []List{}, errors.New("Please set MOZHI_LIBRETRANSLATE_URL if you want to use libretranslate. Example: MOZHI_LIBRETRANSLATE_URL=https://lt.psf.lt")
}
data = LangListLibreTranslate(listType)
} else if engine == "reverso" && EnvTrueNoExist("MOZHI_REVERSO_ENABLED") {
data = LangListReverso(listType)
} else if engine == "deepl" && EnvTrueNoExist("MOZHI_DEEPL_ENABLED") {
data = LangListDeepl(listType)
} else if engine == "watson" && EnvTrueNoExist("MOZHI_WATSON_ENABLED") {
data = LangListWatson(listType)
} else if engine == "yandex" && EnvTrueNoExist("MOZHI_YANDEX_ENABLED") {
data = LangListYandex(listType)
} else if engine == "mymemory" && EnvTrueNoExist("MOZHI_MYMEMORY_ENABLED") {
data = LangListMyMemory(listType)
} else if engine == "duckduckgo" && EnvTrueNoExist("MOZHI_DUCKDUCKGO_ENABLED") {
data = LangListDuckDuckGo(listType)
} else {
return []List{}, errors.New("Engine does not exist or has been disabled.")
}
return data, nil
}
// General function to translate stuff so there is no need for a huge if-block everywhere
func Translate(engine string, to string, from string, text string) (LangOut, error) {
var err error
var data LangOut
if engine == "google" && EnvTrueNoExist("MOZHI_GOOGLE_ENABLED") {
data, err = TranslateGoogle(to, from, text)
} else if engine == "libre" && EnvTrueNoExist("MOZHI_LIBRETRANSLATE_ENABLED") {
if os.Getenv("MOZHI_LIBRETRANSLATE_URL") == "" {
return LangOut{}, errors.New("Please set MOZHI_LIBRETRANSLATE_URL if you want to use libretranslate. Example: MOZHI_LIBRETRANSLATE_URL=https://lt.psf.lt")
}
data, err = TranslateLibreTranslate(to, from, text)
} else if engine == "reverso" && EnvTrueNoExist("MOZHI_REVERSO_ENABLED") {
data, err = TranslateReverso(to, from, text)
} else if engine == "deepl" && EnvTrueNoExist("MOZHI_DEEPL_ENABLED") {
data, err = TranslateDeepl(to, from, text)
} else if engine == "watson" && EnvTrueNoExist("MOZHI_WATSON_ENABLED") {
data, err = TranslateWatson(to, from, text)
} else if engine == "yandex" && EnvTrueNoExist("MOZHI_YANDEX_ENABLED") {
data, err = TranslateYandex(to, from, text)
} else if engine == "mymemory" && EnvTrueNoExist("MOZHI_MYMEMORY_ENABLED") {
data, err = TranslateMyMemory(to, from, text)
} else if engine == "duckduckgo" && EnvTrueNoExist("MOZHI_DUCKDUCKGO_ENABLED") {
data, err = TranslateDuckDuckGo(to, from, text)
} else {
return LangOut{}, errors.New("Engine does not exist or has been disabled.")
}
if err != nil {
return LangOut{}, err
}
return data, nil
}
func TTS(engine string, lang string, text string) ([]byte, error) {
var err error
var data []byte
if engine == "google" && EnvTrueNoExist("MOZHI_GOOGLE_ENABLED") {
data, err = TTSGoogle(lang, text)
} else if engine == "reverso" && EnvTrueNoExist("MOZHI_REVERSO_ENABLED") {
data, err = TTSReverso(lang, text)
} else {
return []byte(""), errors.New("Engine does not exist and/or doesn't support TTS and/or has been disabled.")
}
if err != nil {
return []byte(""), err
}
return data, nil
}

View File

@ -1,72 +0,0 @@
package utils
import (
"bytes"
"io"
"net/http"
"os"
"github.com/tidwall/gjson"
)
func PostRequest(url string, data []byte) gjson.Result {
bodyReader := bytes.NewReader(data)
r, err := http.NewRequest(http.MethodPost, url, bodyReader)
if err != nil {
panic(err)
}
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
if !ok {
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
}
// r.Header.Set("Accept", "application/vnd.github.v3+json")
r.Header.Set("Content-Type", "application/json")
r.Header.Set("User-Agent", UserAgent)
client := &http.Client{}
res, err := client.Do(r)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
jsonified := gjson.Parse(string(body))
return jsonified
}
func GetRequest(url string) gjson.Result {
r, err := http.NewRequest("GET", url, nil)
if err != nil {
panic(err)
}
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
if !ok {
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
}
// r.Header.Set("Content-Type", "application/json")
r.Header.Set("User-Agent", UserAgent)
client := &http.Client{}
res, err := client.Do(r)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
jsonified := gjson.Parse(string(body))
return jsonified
}

View File

@ -1,87 +0,0 @@
package utils
//import (
// "github.com/gocolly/colly"
// "os"
// "strings"
//)
//
//type List struct {
// Name string
// Id string
//}
//// To get new language lists for google yandex and libertranslate.
//func LangListGoogle(listType string) []List {
// UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
// if !ok {
// UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
// }
// sc := colly.NewCollector(colly.AllowedDomains("translate.google.com"), colly.UserAgent(UserAgent))
// var ListData []List
// sc.OnHTML("div.root-container", func(e *colly.HTMLElement) {
// e.ForEach("div.language-item", func(i int, el *colly.HTMLElement) {
// var ListInfo List
// ListInfo.Name = el.ChildText("a")
// if listType == "tl" {
// ListInfo.Id = strings.TrimPrefix(strings.TrimSuffix(el.ChildAttr("a", "href"), "&hl=en-US"), "./m?sl=en&tl=")
// } else {
// ListInfo.Id = strings.TrimPrefix(strings.TrimSuffix(el.ChildAttr("a", "href"), "&tl=en&hl=en-US"), "./m?sl=")
// }
// ListData = append(ListData, ListInfo)
// })
// })
// url := "https://translate.google.com/m?sl=en&tl=en&hl=en-US&mui=" + listType
// sc.Visit(url)
// return ListData
//}
//func LangListLibreTranslate(listType string) []List {
// // TODO: Make it configurable
// libreTranslateOut := PostRequest("https://translate.argosopentech.com/languages", []byte(""))
// gjsonArr := libreTranslateOut.Array()
// var ListData []List
// 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" {
// auto := List{
// Id: "auto",
// Name: "Detect Language",
// }
// ListData = append(ListData, auto)
// }
// return ListData
//}
//func LangListYandex(listType string) []List {
// UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
// if !ok {
// UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
// }
// sc := colly.NewCollector(colly.AllowedDomains("localhost:8000"), colly.UserAgent(UserAgent))
// var ListData []List
// sc.OnHTML("table.langs", func(e *colly.HTMLElement) {
// if listType == "sl" {
// e.ForEach("select[name='from'] option", func(i int, el *colly.HTMLElement) {
// var ListInfo List
// ListInfo.Name = el.Text
// ListInfo.Id = el.Attr("value")
// ListData = append(ListData, ListInfo)
// })
// } else {
// e.ForEach("select[name='to'] option", func(i int, el *colly.HTMLElement) {
// var ListInfo List
// ListInfo.Name = el.Text
// ListInfo.Id = el.Attr("value")
// ListData = append(ListData, ListInfo)
// })
//
// }
// })
// // Static version of translate.yandex.net nojs/mobile version
// url := "http://localhost:8000/index.html"
// sc.Visit(url)
// return ListData
//}
//

View File

@ -1,155 +0,0 @@
package utils
import (
"context"
"encoding/base64"
"os"
"github.com/carlmjohnson/requests"
"github.com/google/go-querystring/query"
)
type ReversoTTS struct {
Id string
Voice string
}
func TTSGoogle(lang string, text string) ([]byte, error) {
type Options struct {
Lang string `url:"tl"`
Text string `url:"q"`
Client string `url:"client"`
}
opt := Options{lang, text, "tw-ob"}
v, _ := query.Values(opt)
var file string
url := "https://translate.google.com/translate_tts?" + v.Encode()
err := requests.
URL(url).
ToString(&file).
Fetch(context.Background())
if err != nil {
return []byte(""), err
}
return []byte(file), nil
}
func TTSReverso(lang string, text string) ([]byte, error) {
TTSData := []ReversoTTS{
// http://voice.reverso.net/RestPronunciation.svc/v1/output=json/GetAvailableVoices with randomized deduplication
{
Id: "ar",
Voice: "Mehdi22k",
},
{
Id: "zh",
Voice: "Lulu22k",
},
{
Id: "cz",
Voice: "Eliska22k",
},
{
Id: "dk",
Voice: "Mette22k",
},
{
Id: "nl",
Voice: "Daan22k",
},
{
Id: "en",
Voice: "Will22k",
},
{
Id: "fr",
Voice: "Margaux22k",
},
{
Id: "de",
Voice: "Andreas22k",
},
{
Id: "gr",
Voice: "Dimitris22k",
},
{
Id: "heb",
Voice: "he-IL-Asaf",
},
{
Id: "it",
Voice: "Chiara22k",
},
{
Id: "jp",
Voice: "Sakura22k",
},
{
Id: "kr",
Voice: "Minji22k",
},
{
Id: "pl",
Voice: "Monika22k",
},
{
Id: "pt",
Voice: "Celia22k",
},
{
Id: "ro",
Voice: "ro-RO-Andrei",
},
{
Id: "ru",
Voice: "Alyona22k",
},
{
Id: "es",
Voice: "Antonio22k",
},
{
Id: "se",
Voice: "Erik22k",
},
{
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
}
}
type Options struct {
VoiceSpeed int `url:"voiceSpeed"`
Text string `url:"inputText"`
}
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()
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
if !ok {
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
}
err := requests.
URL(url).
ToString(&file).
UserAgent(UserAgent).
Fetch(context.Background())
if err != nil {
return []byte(""), err
}
return []byte(file), nil
}

View File

@ -1,19 +0,0 @@
package utils
import (
"runtime/debug"
)
var Branch = "Alpha"
// Version returns the git commit hash of the current build. Taken from https://git.vern.cc/pjals/bestofbot.
func Version() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value[:8]
}
}
}
return "unknown, please build with Go 1.13+ or use Git"
}