add envvar to prefer autodetect over source lang
Some checks are pending
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 31m23s
mozhi pipeline / Build and publish artifacts (push) Has started running

This commit is contained in:
Arya 2024-05-27 19:37:58 +05:30
parent bf61d39f12
commit e80e5482f2
Signed by: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 3 additions and 1 deletions

View File

@ -53,6 +53,7 @@ Features of Mozhi can be customized and toggled on/off using Environment Variabl
- `MOZHI_PORT`: Port the webserver listens on (if hosting API)
- `MOZHI_LIBRETRANSLATE_URL`: URL of Libretranslate instance (Example: `MOZHI_LIBRETRANSLATE_URL=https://lt.psf.lt`)
- `MOZHI_DEFAULT_SOURCE_LANG`: Language to default to if no source language is set by user. Defaults to Auto-Detect (or first available language in engines which dont support it)
- `MOZHI_DEFAULT_PREFER_AUTODETECT`: Prefer autodetect if available instead of specified/default source language. Defaults to false
- `MOZHI_DEFAULT_TARGET_LANG`: Language to default to if no target language is set by user. Defaults to English
These envvars turn off/on engines. By default all of them are enabled.

View File

@ -93,8 +93,9 @@ func HandleIndex(c *fiber.Ctx) error {
}
defaultLang := os.Getenv("MOZHI_DEFAULT_SOURCE_LANG")
preferAutoDetect := os.Getenv("MOZHI_DEFAULT_PREFER_AUTODETECT")
defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG")
if defaultLang == "" {
if defaultLang == "" || preferAutoDetect == "true" {
defaultLang = "auto"
}
if defaultLangTarget == "" {