fix default source lang (closes #41)

This commit is contained in:
Arya Kiran 2024-06-27 20:38:29 +05:30
parent 16813c4db5
commit 197949150d
No known key found for this signature in database
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")
preferAutoDetect := os.Getenv("MOZHI_DEFAULT_PREFER_AUTODETECT")
defaultLangTarget := os.Getenv("MOZHI_DEFAULT_TARGET_LANG")
if defaultLang == "" || preferAutoDetect == "true" {
if defaultLang == "" || (preferAutoDetect == "true" && sourceLanguages[0].Id == "auto") {
defaultLang = "auto"
}
if defaultLangTarget == "" {

View file

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