Files
magpie/internal/gui/syshourcycle_darwin.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

25 lines
662 B
Go

package gui
import "github.com/yetone/magpie/internal/proc"
func readHourCycle() string {
read := func(key string) string {
out, err := proc.Command("defaults", "read", "-g", key).Output()
if err != nil {
return ""
}
return string(out)
}
return forcedHourCycle(read("AppleICUForce24HourTime"), read("AppleICUForce12HourTime"))
}
// readLocale is AppleLocale, the language and region the user picked in
// System Settings (en_JP), which is what macOS itself formats dates with.
func readLocale() string {
out, err := proc.Command("defaults", "read", "-g", "AppleLocale").Output()
if err != nil {
return ""
}
return localeTag(string(out))
}