mirror of
https://codeberg.org/aryak/mozhi
synced 2024-11-22 23:52:57 +05:30
add envvar to prefer autodetect over source lang
This commit is contained in:
parent
bf61d39f12
commit
e80e5482f2
@ -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_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_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_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
|
- `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.
|
These envvars turn off/on engines. By default all of them are enabled.
|
||||||
|
@ -93,8 +93,9 @@ func HandleIndex(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultLang := os.Getenv("MOZHI_DEFAULT_SOURCE_LANG")
|
defaultLang := os.Getenv("MOZHI_DEFAULT_SOURCE_LANG")
|
||||||
|
preferAutoDetect := os.Getenv("MOZHI_DEFAULT_PREFER_AUTODETECT")
|
||||||
defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG")
|
defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG")
|
||||||
if defaultLang == "" {
|
if defaultLang == "" || preferAutoDetect == "true" {
|
||||||
defaultLang = "auto"
|
defaultLang = "auto"
|
||||||
}
|
}
|
||||||
if defaultLangTarget == "" {
|
if defaultLangTarget == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user