package web import ( "strings" "testing" "time" ) // R-562 (`09` §3 decision 223): the dashboard prints dates and numbers the reader's way — Hungarian // „2026. 09. 14. 05:12" and a decimal comma, English „2026-09-14 05:12" and a decimal point. Asserted // on a RENDERED page in both languages (the backups page carries a date-time and a GB size), and on // the func set the templates call. // // RED-PROOF (REPORT.md): make i18n.FormatDateTime / FormatDecimal ignore the language → the // Hungarian half fails. func TestR562_BackupsPageFormatsPerLanguage(t *testing.T) { var c i18nCase for _, x := range i18nCases() { if x.name == "backups_full" { c = x } } if c.name == "" { t.Fatal("parity case backups_full not found") } s := i18nTestServer(t) hu := renderI18nCase(t, s, "hu", c) en := renderI18nCase(t, s, "en", c) for _, want := range []string{"2026. 09. 14. 05:12", "5,0 GB", "42,5 GB"} { if !strings.Contains(hu, want) { t.Errorf("hu: the page does not carry %q", want) } } for _, bad := range []string{"2026-09-14 05:12", "5.0 GB"} { if strings.Contains(hu, bad) { t.Errorf("hu: the page still carries the ISO/point form %q", bad) } } for _, want := range []string{"2026-09-14 05:12", "5.0 GB", "42.5 GB"} { if !strings.Contains(en, want) { t.Errorf("en: the page does not carry %q", want) } } if strings.Contains(en, "2026. 09. 14.") || strings.Contains(en, "5,0 GB") { t.Error("en: the page carries the Hungarian date or decimal comma") } } func TestR562_FormatFuncsPerLanguage(t *testing.T) { at := time.Date(2026, 10, 10, 13, 4, 0, 0, time.UTC) // 15:04 in Budapest (CEST) hu, en := formatFuncs("hu"), formatFuncs("en") check := func(name, got, want string) { t.Helper() if got != want { t.Errorf("%s: got %q, want %q", name, got, want) } } check("hu fmtTime", hu["fmtTime"].(func(time.Time) string)(at), "2026. 10. 10. 15:04") check("en fmtTime", en["fmtTime"].(func(time.Time) string)(at), "2026-10-10 15:04") check("hu fmtTimeStr", hu["fmtTimeStr"].(func(string) string)("2026-10-10T13:04:00Z"), "2026. 10. 10. 15:04") check("en fmtTimeStr", en["fmtTimeStr"].(func(string) string)("2026-10-10T13:04:00Z"), "2026-10-10 15:04") check("hu fmtGB", hu["fmtGB"].(func(float64) string)(42.5), "42,5 GB") check("en fmtGB", en["fmtGB"].(func(float64) string)(42.5), "42.5 GB") check("hu fmtBytes", hu["fmtBytes"].(func(int64) string)(1610612736), "1,5 GB") check("en fmtBytes", en["fmtBytes"].(func(int64) string)(1610612736), "1.5 GB") check("hu fmtLoad", hu["fmtLoad"].(func(float64) string)(0.25), "0,25") check("en fmtLoad", en["fmtLoad"].(func(float64) string)(0.25), "0.25") check("hu numText", hu["numText"].(func(string) string)("12.0 MB"), "12,0 MB") check("en numText", en["numText"].(func(string) string)("12.0 MB"), "12.0 MB") check("zero time", hu["fmtTime"].(func(time.Time) string)(time.Time{}), "–") }