SimplyTranslate -> Mozhi + Refactor README
This commit is contained in:
parent
e666fc63cc
commit
2efcf283b7
20 changed files with 65 additions and 37 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -19,7 +19,7 @@
|
||||||
# vendor/
|
# vendor/
|
||||||
|
|
||||||
# Simplytranslate binary (on linux and mac)
|
# Simplytranslate binary (on linux and mac)
|
||||||
/simplytranslate
|
/mozhi
|
||||||
|
|
||||||
# Go workspace file
|
# Go workspace file
|
||||||
go.work
|
go.work
|
||||||
|
|
32
README.md
32
README.md
|
@ -1,4 +1,30 @@
|
||||||
# Another rewrite of simplytranslate in Go
|
# Mozhi
|
||||||
Basically, simplytranslate has been dead for a while and I want to remake it, but with some QoL improvements ofc :)
|
Mozhi (spelt moḻi) is an alternative-frontend for many translation engines.
|
||||||
|
|
||||||
I'm initially focusing on the api/engines part, but eventually ill get around to setting up the gofiber thing. I plan on making it a combined cli+webui
|
It was initially made as a maintained fork/rewrite of [simplytranslate](https://codeberg.org/SimpleWeb/SimplyTranslate-Web), but has grown to have a lot more features as well!
|
||||||
|
|
||||||
|
I'm initially focusing on the api and engines, but eventually Mozhi will have a functioning CLI and webapp.
|
||||||
|
|
||||||
|
## Supported Engines:
|
||||||
|
- Google
|
||||||
|
- Reverso
|
||||||
|
- DeepL
|
||||||
|
- LibreTranslate
|
||||||
|
- Yandex
|
||||||
|
- IBM Watson
|
||||||
|
- MyMemory
|
||||||
|
- DuckDuckGo (almost 1-1 with Bing Translate)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Just `go build` and you're done :D
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- An all mode where the responses of all supported engines will be shown.
|
||||||
|
- Autodetect which will show the language that was detected
|
||||||
|
- Tesseract based image recognition (it isn't that good to be fair but it works nontheless)
|
||||||
|
- Text-To-Speech for multiple engines
|
||||||
|
- A good API (subjective :P)
|
||||||
|
- All the stuff you expect from a translation utility :)
|
||||||
|
|
||||||
|
## Etymology
|
||||||
|
Mozhi is the word in Tamil for language. Simple as that :P
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -1,5 +1,7 @@
|
||||||
# TODO
|
# TODO
|
||||||
- Create a web interface
|
- Create a web interface
|
||||||
|
- Make CLI usable
|
||||||
|
- Add actual explanations for CLI arguments
|
||||||
- Proper Error handling for requests.go
|
- Proper Error handling for requests.go
|
||||||
- Tell which language Detect Language chose -- Only support for deepl and google is pending
|
- Tell which language Detect Language chose -- Only support for deepl and google is pending
|
||||||
- Finish simplytranslate-py compatible API for translations
|
- Finish simplytranslate-py compatible API for translations
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"codeberg.org/aryak/simplytranslate/utils"
|
"codeberg.org/aryak/mozhi/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ var imgtxtCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(imgtxtCmd)
|
rootCmd.AddCommand(imgtxtCmd)
|
||||||
|
|
||||||
imgtxtCmd.Flags().StringVarP(&file, "file", "f", "", "The query SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_query environment variable.")
|
imgtxtCmd.Flags().StringVarP(&file, "file", "f", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
|
||||||
|
|
||||||
langlist = imgtxtCmd.Flag("file").Value.String()
|
langlist = imgtxtCmd.Flag("file").Value.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "simplytranslate",
|
Use: "mozhi",
|
||||||
Short: "An alternative front-end for many Translation Engines.",
|
Short: "An alternative front-end for many Translation Engines.",
|
||||||
Long: "An alternative front-end for many Translation Engines, rewritten in Gofiber+colly by AryaK.",
|
Long: "An alternative front-end for many Translation Engines, rewritten in Gofiber+colly by AryaK.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"codeberg.org/aryak/simplytranslate/serve"
|
"codeberg.org/aryak/mozhi/serve"
|
||||||
)
|
)
|
||||||
|
|
||||||
var port string = "3000"
|
var port string = "3000"
|
||||||
|
@ -20,7 +20,7 @@ var serveCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(serveCmd)
|
rootCmd.AddCommand(serveCmd)
|
||||||
|
|
||||||
serveCmd.Flags().StringVarP(&port, "port", "p", "", "The port SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_PORT environment variable.")
|
serveCmd.Flags().StringVarP(&port, "port", "p", "", "The port Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_PORT environment variable.")
|
||||||
|
|
||||||
// set port variable to the value of the port flag
|
// set port variable to the value of the port flag
|
||||||
port = serveCmd.Flag("port").Value.String()
|
port = serveCmd.Flag("port").Value.String()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"codeberg.org/aryak/simplytranslate/utils"
|
"codeberg.org/aryak/mozhi/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -90,11 +90,11 @@ var translateCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(translateCmd)
|
rootCmd.AddCommand(translateCmd)
|
||||||
|
|
||||||
translateCmd.Flags().StringVarP(&engine, "engine", "e", "", "The source SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_source environment variable.")
|
translateCmd.Flags().StringVarP(&engine, "engine", "e", "", "The source Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_source environment variable.")
|
||||||
translateCmd.Flags().StringVarP(&source, "source", "s", "", "The source SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_source environment variable.")
|
translateCmd.Flags().StringVarP(&source, "source", "s", "", "The source Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_source environment variable.")
|
||||||
translateCmd.Flags().StringVarP(&dest, "dest", "t", "", "The dest SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_dest environment variable.")
|
translateCmd.Flags().StringVarP(&dest, "dest", "t", "", "The dest Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_dest environment variable.")
|
||||||
translateCmd.Flags().StringVarP(&query, "query", "q", "", "The query SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_query environment variable.")
|
translateCmd.Flags().StringVarP(&query, "query", "q", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
|
||||||
translateCmd.Flags().StringVarP(&langlist, "langlist", "l", "", "The query SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_query environment variable.")
|
translateCmd.Flags().StringVarP(&langlist, "langlist", "l", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
|
||||||
|
|
||||||
engine = translateCmd.Flag("engine").Value.String()
|
engine = translateCmd.Flag("engine").Value.String()
|
||||||
dest = translateCmd.Flag("dest").Value.String()
|
dest = translateCmd.Flag("dest").Value.String()
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module codeberg.org/aryak/simplytranslate
|
module codeberg.org/aryak/mozhi
|
||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -1,6 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "codeberg.org/aryak/simplytranslate/cmd"
|
import "codeberg.org/aryak/mozhi/cmd"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Everything that matters is in /cmd
|
// Everything that matters is in /cmd
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package pages
|
package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"codeberg.org/aryak/simplytranslate/utils"
|
"codeberg.org/aryak/mozhi/utils"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package pages
|
package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"codeberg.org/aryak/simplytranslate/utils"
|
"codeberg.org/aryak/mozhi/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"codeberg.org/aryak/simplytranslate/pages"
|
"codeberg.org/aryak/mozhi/pages"
|
||||||
"codeberg.org/aryak/simplytranslate/utils"
|
"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"
|
||||||
|
@ -33,7 +33,7 @@ func Serve(port string) {
|
||||||
app := fiber.New(fiber.Config{
|
app := fiber.New(fiber.Config{
|
||||||
Views: engine,
|
Views: engine,
|
||||||
Prefork: false,
|
Prefork: false,
|
||||||
AppName: "SimplyTranslate",
|
AppName: "Mozhi",
|
||||||
// kind of screwed up way to fix rate limits
|
// kind of screwed up way to fix rate limits
|
||||||
EnableTrustedProxyCheck: true,
|
EnableTrustedProxyCheck: true,
|
||||||
TrustedProxies: []string{"0.0.0.0/0"},
|
TrustedProxies: []string{"0.0.0.0/0"},
|
||||||
|
@ -99,7 +99,7 @@ func Serve(port string) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
val, ok := os.LookupEnv("SIMPLYTRANSLATE_PORT")
|
val, ok := os.LookupEnv("MOZHI_PORT")
|
||||||
if !ok {
|
if !ok {
|
||||||
val = "3000"
|
val = "3000"
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func TranslateGoogle(to string, from string, text string) (LangOut, error) {
|
||||||
return LangOut{}, errors.New("Source language code invalid")
|
return LangOut{}, errors.New("Source language code invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
|
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
if !ok {
|
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"
|
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ func PostRequest(url string, data []byte) gjson.Result {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
|
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
if !ok {
|
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"
|
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func GetRequest(url string) gjson.Result {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
|
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
if !ok {
|
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"
|
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ package utils
|
||||||
//}
|
//}
|
||||||
//// 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 {
|
//func LangListGoogle(listType string) []List {
|
||||||
// UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
|
// UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
// if !ok {
|
// 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"
|
// UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
// }
|
// }
|
||||||
|
@ -55,7 +55,7 @@ package utils
|
||||||
// return ListData
|
// return ListData
|
||||||
//}
|
//}
|
||||||
//func LangListYandex(listType string) []List {
|
//func LangListYandex(listType string) []List {
|
||||||
// UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT")
|
// UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
// if !ok {
|
// 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"
|
// UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -137,7 +137,7 @@ func TTSReverso(lang string, text string) []byte {
|
||||||
var file string
|
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")
|
UserAgent, ok := os.LookupEnv("MOZHI_USER_AGENT")
|
||||||
if !ok {
|
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"
|
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<pre class="error">{{.error}}</pre>
|
<pre class="error">{{.error}}</pre>
|
||||||
<h3>
|
<h3>
|
||||||
Think this is a bug?
|
Think this is a bug?
|
||||||
<a href="https://codeberg.org/aryak/simplytranslate/issues" target="_blank"
|
<a href="https://codeberg.org/aryak/mozhi/issues" target="_blank"
|
||||||
>Create an issue on Codeberg.</a
|
>Create an issue on Codeberg.</a
|
||||||
>
|
>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<footer class="center">
|
<footer class="center">
|
||||||
<a href="https://codeberg.org/aryak/simplytranslate">Codeberg</a> | <a href="/instance">About Instance</a>
|
<a href="https://codeberg.org/aryak/mozhi">Codeberg</a> | <a href="/instance">About Instance</a>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
{{ if .title }}
|
{{ if .title }}
|
||||||
<title>{{ .title }} - SimplyTranslate</title>
|
<title>{{ .title }} - Mozhi</title>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<title>SimplyTranslate</title>
|
<title>Mozhi</title>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<link rel="stylesheet" href="/css/global.css">
|
<link rel="stylesheet" href="/css/global.css">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{template "header" .}}
|
{{template "header" .}}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<h2>SimplyTranslate</h2>
|
<h2>Mozhi</h2>
|
||||||
<h3>Translate</h3>
|
<h3>Translate</h3>
|
||||||
|
|
||||||
<form action="/" method="get">
|
<form action="/" method="get">
|
||||||
|
@ -16,9 +16,9 @@
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
<h3>Info</h3>
|
<h3>Info</h3>
|
||||||
{{ if eq .version "unknown, please build with Go 1.13+ or use Git"}} SimplyTranslate
|
{{ if eq .version "unknown, please build with Go 1.13+ or use Git"}} Mozhi
|
||||||
version: <code>unknown</code> {{ else }} SimplyTranslate version:
|
version: <code>unknown</code> {{ else }} Mozhi version:
|
||||||
<a href="https://codeberg.org/aryak/simplytranslate/commit/{{ .version}}"
|
<a href="https://codeberg.org/aryak/mozhi/commit/{{ .version}}"
|
||||||
><code>{{ .version}}</code></a
|
><code>{{ .version}}</code></a
|
||||||
>
|
>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue