add selectable engines support to web (closes #20)
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 19m45s
mozhi pipeline / Build and publish artifacts (push) Successful in 1h5m59s

This commit is contained in:
2024-08-27 22:36:11 +05:30
parent a2ac174314
commit 0c2c0f7dfd
5 changed files with 78 additions and 19 deletions

View File

@@ -1,10 +1,11 @@
package utils
import (
"codeberg.org/aryak/libmozhi"
"github.com/gofiber/fiber/v2"
"os"
"regexp"
"codeberg.org/aryak/libmozhi"
"github.com/gofiber/fiber/v2"
)
var nonAlphanumericRegex = regexp.MustCompile(`[^a-zA-Z,]+`)
@@ -34,7 +35,7 @@ func Sanitize(str string, strip string) string {
}
func EngineList() map[string]string {
engines := map[string]string{"all": "All Engines", "google": "Google", "deepl": "DeepL", "duckduckgo": "DuckDuckGo", "libre": "LibreTranslate", "mymemory": "MyMemory", "reverso": "Reverso", "yandex": "Yandex"}
engines := map[string]string{"all": "All Engines", "some": "Some Engines", "google": "Google", "deepl": "DeepL", "duckduckgo": "DuckDuckGo", "libre": "LibreTranslate", "mymemory": "MyMemory", "reverso": "Reverso", "yandex": "Yandex"}
if EnvTrueNoExist("MOZHI_GOOGLE_ENABLED") == false {
delete(engines, "google")
} else if EnvTrueNoExist("MOZHI_DEEPL_ENABLED") == false {