fix default source lang (closes #41)
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 37m21s
mozhi pipeline / Build and publish artifacts (push) Successful in 1h30m52s

This commit is contained in:
Arya 2024-06-27 20:38:29 +05:30
parent 16813c4db5
commit 197949150d
Signed by: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 3 additions and 3 deletions

View File

@ -95,7 +95,7 @@ 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") preferAutoDetect := os.Getenv("MOZHI_DEFAULT_PREFER_AUTODETECT")
defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG") defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG")
if defaultLang == "" || preferAutoDetect == "true" { if defaultLang == "" || (preferAutoDetect == "true" && sourceLanguages[0].Id == "auto") {
defaultLang = "auto" defaultLang = "auto"
} }
if defaultLangTarget == "" { if defaultLangTarget == "" {

View File

@ -21,11 +21,11 @@
<div class="language"> <div class="language">
<select name="from" aria-label="Source language" id="sourceLanguage"> <select name="from" aria-label="Source language" id="sourceLanguage">
{{ range $key, $value := .SourceLanguages }} {{ if eq $.From "" }} {{ range $key, $value := .SourceLanguages }} {{ if eq $.From "" }}
<option value="{{ .Id }}" {{ if eq $.From .Id }}selected{{ end }}> <option value="{{ .Id }}" {{ if eq .Id $.defaultLang }}selected{{ end }}>
{{ .Name }} {{ .Name }}
</option> </option>
{{ else }} {{ else }}
<option value="{{ .Id }}" {{ if eq .Id $.defaultLang }}selected{{ end }}> <option value="{{ .Id }}" {{ if eq $.From .Id }}selected{{ end }}>
{{ .Name }} {{ .Name }}
</option> </option>
{{ end }} {{ end }} {{ end }} {{ end }}