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.
32 lines
768 B
Go
32 lines
768 B
Go
package gui
|
|
|
|
import "golang.org/x/sys/windows/registry"
|
|
|
|
func readHourCycle() string {
|
|
k, err := registry.OpenKey(registry.CURRENT_USER, `Control Panel\International`, registry.QUERY_VALUE)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
defer k.Close()
|
|
f, _, err := k.GetStringValue("sTimeFormat")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return windowsHourCycle(f)
|
|
}
|
|
|
|
// readLocale is the regional format (Control Panel → International,
|
|
// LocaleName), which is not the display language WebView2 reports.
|
|
func readLocale() string {
|
|
k, err := registry.OpenKey(registry.CURRENT_USER, `Control Panel\International`, registry.QUERY_VALUE)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
defer k.Close()
|
|
n, _, err := k.GetStringValue("LocaleName")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return localeTag(n)
|
|
}
|