diff --git a/.gitignore b/.gitignore index 59cf7e1..11761ae 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ # vendor/ # Simplytranslate binary (on linux and mac) -/simplytranslate +/mozhi # Go workspace file go.work diff --git a/README.md b/README.md index 6ed8634..c058854 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ -# Another rewrite of simplytranslate in Go -Basically, simplytranslate has been dead for a while and I want to remake it, but with some QoL improvements ofc :) +# Mozhi +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 diff --git a/TODO.md b/TODO.md index 1240cf7..95d2456 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,7 @@ # TODO - Create a web interface +- Make CLI usable +- Add actual explanations for CLI arguments - Proper Error handling for requests.go - Tell which language Detect Language chose -- Only support for deepl and google is pending - Finish simplytranslate-py compatible API for translations diff --git a/cmd/imgtxt.go b/cmd/imgtxt.go index 4347d24..357218e 100644 --- a/cmd/imgtxt.go +++ b/cmd/imgtxt.go @@ -1,7 +1,7 @@ package cmd import ( - "codeberg.org/aryak/simplytranslate/utils" + "codeberg.org/aryak/mozhi/utils" "fmt" "github.com/spf13/cobra" ) @@ -25,7 +25,7 @@ var imgtxtCmd = &cobra.Command{ func init() { 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() } diff --git a/cmd/root.go b/cmd/root.go index 7284879..07e134f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,7 +8,7 @@ import ( ) var rootCmd = &cobra.Command{ - Use: "simplytranslate", + Use: "mozhi", Short: "An alternative front-end for many Translation Engines.", Long: "An alternative front-end for many Translation Engines, rewritten in Gofiber+colly by AryaK.", Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/serve.go b/cmd/serve.go index 6cbd6cd..b0f28f6 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/spf13/cobra" - "codeberg.org/aryak/simplytranslate/serve" + "codeberg.org/aryak/mozhi/serve" ) var port string = "3000" @@ -20,7 +20,7 @@ var serveCmd = &cobra.Command{ func init() { 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 port = serveCmd.Flag("port").Value.String() diff --git a/cmd/translate.go b/cmd/translate.go index d2f60a1..28f3943 100644 --- a/cmd/translate.go +++ b/cmd/translate.go @@ -1,7 +1,7 @@ package cmd import ( - "codeberg.org/aryak/simplytranslate/utils" + "codeberg.org/aryak/mozhi/utils" "fmt" "github.com/spf13/cobra" ) @@ -90,11 +90,11 @@ var translateCmd = &cobra.Command{ func init() { 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(&source, "source", "s", "", "The source SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_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(&query, "query", "q", "", "The query SimplyTranslate will listen to. Defaults to 3000, and overrides the SIMPLYTRANSLATE_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(&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 Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_source 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 Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_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() dest = translateCmd.Flag("dest").Value.String() diff --git a/go.mod b/go.mod index beecf29..17dfcd4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module codeberg.org/aryak/simplytranslate +module codeberg.org/aryak/mozhi go 1.20 diff --git a/main.go b/main.go index 67c81f3..c05ca35 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -import "codeberg.org/aryak/simplytranslate/cmd" +import "codeberg.org/aryak/mozhi/cmd" func main() { // Everything that matters is in /cmd diff --git a/pages/api.go b/pages/api.go index f30dadf..8af17df 100644 --- a/pages/api.go +++ b/pages/api.go @@ -1,7 +1,7 @@ package pages import ( - "codeberg.org/aryak/simplytranslate/utils" + "codeberg.org/aryak/mozhi/utils" "github.com/gofiber/fiber/v2" ) diff --git a/pages/index.go b/pages/index.go index 615c9d0..001bbce 100644 --- a/pages/index.go +++ b/pages/index.go @@ -1,7 +1,7 @@ package pages import ( - "codeberg.org/aryak/simplytranslate/utils" + "codeberg.org/aryak/mozhi/utils" "fmt" "github.com/gofiber/fiber/v2" "runtime" diff --git a/serve/serve.go b/serve/serve.go index 5584991..7180f64 100644 --- a/serve/serve.go +++ b/serve/serve.go @@ -6,8 +6,8 @@ import ( "os" "runtime" - "codeberg.org/aryak/simplytranslate/pages" - "codeberg.org/aryak/simplytranslate/utils" + "codeberg.org/aryak/mozhi/pages" + "codeberg.org/aryak/mozhi/utils" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/compress" @@ -33,7 +33,7 @@ func Serve(port string) { app := fiber.New(fiber.Config{ Views: engine, Prefork: false, - AppName: "SimplyTranslate", + AppName: "Mozhi", // kind of screwed up way to fix rate limits EnableTrustedProxyCheck: true, 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 { val = "3000" } diff --git a/utils/engines.go b/utils/engines.go index 5127f4c..708daf0 100644 --- a/utils/engines.go +++ b/utils/engines.go @@ -47,7 +47,7 @@ func TranslateGoogle(to string, from string, text string) (LangOut, error) { return LangOut{}, errors.New("Source language code invalid") } - UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT") + 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" } diff --git a/utils/requests.go b/utils/requests.go index 3efb7e7..dd8b5ed 100644 --- a/utils/requests.go +++ b/utils/requests.go @@ -15,7 +15,7 @@ func PostRequest(url string, data []byte) gjson.Result { panic(err) } - UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT") + 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" } @@ -45,7 +45,7 @@ func GetRequest(url string) gjson.Result { panic(err) } - UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT") + 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" } diff --git a/utils/retrieve.go b/utils/retrieve.go index 01a75f2..d3d3e05 100644 --- a/utils/retrieve.go +++ b/utils/retrieve.go @@ -12,7 +12,7 @@ package utils //} //// To get new language lists for google yandex and libertranslate. //func LangListGoogle(listType string) []List { -// UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT") +// 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" // } @@ -55,7 +55,7 @@ package utils // return ListData //} //func LangListYandex(listType string) []List { -// UserAgent, ok := os.LookupEnv("SIMPLYTRANSLATE_USER_AGENT") +// 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" // } diff --git a/utils/tts.go b/utils/tts.go index 956bcab..7a1820a 100644 --- a/utils/tts.go +++ b/utils/tts.go @@ -137,7 +137,7 @@ func TTSReverso(lang string, text string) []byte { var file string 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 { UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36" } diff --git a/views/error.html b/views/error.html index 98601e9..7797974 100644 --- a/views/error.html +++ b/views/error.html @@ -9,7 +9,7 @@
{{.error}}

Think this is a bug? - Create an issue on Codeberg.

diff --git a/views/footer.html b/views/footer.html index 488718e..2e94034 100644 --- a/views/footer.html +++ b/views/footer.html @@ -1,5 +1,5 @@ diff --git a/views/header.html b/views/header.html index 11fe9db..c67cd77 100644 --- a/views/header.html +++ b/views/header.html @@ -2,9 +2,9 @@ {{ if .title }} - {{ .title }} - SimplyTranslate + {{ .title }} - Mozhi {{ else }} - SimplyTranslate + Mozhi {{ end }} diff --git a/views/index.html b/views/index.html index b1c158d..232816c 100644 --- a/views/index.html +++ b/views/index.html @@ -1,7 +1,7 @@ {{template "header" .}}
-

SimplyTranslate

+

Mozhi

Translate

@@ -16,9 +16,9 @@

Info

- {{ if eq .version "unknown, please build with Go 1.13+ or use Git"}} SimplyTranslate - version: unknown {{ else }} SimplyTranslate version: - unknown {{ else }} Mozhi version: + {{ .version}} {{ end }}