Files
magpie/internal/gui/syshourcycle_other.go
T
yetone 4940aed1d8 gui: times follow the system's region, not the webview's (iXerol on X)
A Mac set to English with Japan as its region (AppleLocale en_JP, 24
hours) showed 12 hours: with neither AppleICUForce24HourTime nor
AppleICUForce12HourTime set, the page formatted in WKWebView's
navigator.language (en-US). boot.js now carries the system's own tag as
"locale" (macOS: `defaults read -g AppleLocale`, with @rg= winning;
Windows: Control Panel\International LocaleName; Linux: LC_ALL, LC_TIME,
LANG), and intlLang takes it over navigator.language for English. The two
forced clock switches still win over the region's clock. A browser tab
keeps its own locale.

Run (mica): go test -run 'HourCycle|LocaleTag|Boot' ./internal/gui ok;
gofmt -l clean; go vet darwin, linux nogui, windows on internal/gui clean;
GUI hc-clock, reset-clock-formats, dates-gui-lang, i18n-keys, header-relang,
desktop-lang in chromium and webkit: 0 fail. Real AppleLocale on this Mac
reads en_SG. Broken by hand: intlLang back to navigator.language turns the
new en-JP case red in both engines. Not tried: a real Windows or Linux
session with a regional format that differs from the display language; full
suite starts after the tag.
2026-11-12 17:16:34 +08:00

32 lines
779 B
Go

//go:build !darwin && !windows
package gui
import (
"os"
"github.com/yetone/magpie/internal/proc"
)
// readHourCycle asks GNOME (and what follows its setting: Cinnamon,
// Budgie, Omarchy's GNOME apps) for the clock format; other desktops say
// nothing, and the page keeps its locale's own.
func readHourCycle() string {
out, err := proc.Command("gsettings", "get", "org.gnome.desktop.interface", "clock-format").Output()
if err != nil {
return ""
}
return gnomeHourCycle(string(out))
}
// readLocale is the locale the session sets for times (LC_ALL, LC_TIME,
// then LANG), as every GTK app reads it.
func readLocale() string {
for _, k := range []string{"LC_ALL", "LC_TIME", "LANG"} {
if v := os.Getenv(k); v != "" {
return localeTag(v)
}
}
return ""
}