Fix locale initialization logic (#2619)

* Fix locale initialization logic

* add comment

* Update main.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update GitHub Actions workflow for testing

* Update GitHub Actions workflow to allow artifact overwrite

* Update GitHub Actions workflow to allow artifact overwrite

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jo
2025-05-06 18:16:47 +02:00
committed by GitHub
parent 98be3fec97
commit 8ab3652846
2 changed files with 20 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"runtime/debug"
"strings"
"github.com/leonelquinteros/gotext"
@@ -27,7 +28,12 @@ func initGotext() {
}
if lc := os.Getenv("LANGUAGE"); lc != "" {
gotext.Configure(localePath, lc, "yay")
// Split LANGUAGE by ':' and prioritize the first locale
// Should fix in gotext to support this
locales := strings.Split(lc, ":")
if len(locales) > 0 && locales[0] != "" {
gotext.Configure(localePath, locales[0], "yay")
}
} else if lc := os.Getenv("LC_ALL"); lc != "" {
gotext.Configure(localePath, lc, "yay")
} else if lc := os.Getenv("LC_MESSAGES"); lc != "" {