612c417024
gates / gates (push) Successful in 19s
Message bundles (internal/i18n) expanded into templates before parsing, one template set per language. Launcher, /backups, /apps/<slug> and the layout converted; household language setting, POST /settings/language, ?lang= override, report field. Parity test against fixtures captured from unconverted templates; copy gates read templates expanded; new i18n_missing_gate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
36 lines
966 B
Go
36 lines
966 B
Go
package settings
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// i18n (v0.247.0): the household language. Default Hungarian; only a supported value is stored; the
|
|
// choice survives a restart (it is what the hub report and every page read).
|
|
func TestLanguageSetting(t *testing.T) {
|
|
lg := log.New(io.Discard, "", 0)
|
|
p := filepath.Join(t.TempDir(), "settings.json")
|
|
s, err := Load(p, lg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := s.GetLanguage(); got != "hu" {
|
|
t.Fatalf("a box that never chose must read Hungarian, got %q", got)
|
|
}
|
|
if err := s.SetLanguage("de"); err == nil || s.GetLanguage() != "hu" {
|
|
t.Fatalf("unsupported language must be refused and change nothing (err=%v, lang=%q)", err, s.GetLanguage())
|
|
}
|
|
if err := s.SetLanguage("en"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
again, err := Load(p, lg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := again.GetLanguage(); got != "en" {
|
|
t.Fatalf("language did not survive a reload: %q", got)
|
|
}
|
|
}
|