package i18n_test import ( "strings" "testing" "testing/fstest" "time" "github.com/noderunners/dlbot/internal/i18n" "github.com/noderunners/dlbot/internal/ytdlp" "github.com/noderunners/dlbot/locales" ) func load(t *testing.T) *i18n.Bundle { t.Helper() b, err := i18n.Load(locales.FS, nil) if err != nil { t.Fatal(err) } return b } func TestEveryErrorCodeHasAMessage(t *testing.T) { b := load(t) for _, code := range ytdlp.KnownCodes { if !b.Has("en", "error."+string(code)) { t.Errorf("the en catalog has no message for error.%s", code) } } } func TestPluralsAndArgs(t *testing.T) { b := load(t) if got := b.T("en", "unit.minutes", i18n.Args{"Count": 1}); got != "1 minute" { t.Errorf("one = %q", got) } if got := b.T("en", "unit.minutes", i18n.Args{"Count": 5}); got != "5 minutes" { t.Errorf("other = %q", got) } if got := b.T("en", "btn.res", i18n.Args{"Height": 720}); got != "720p" { t.Errorf("btn.res = %q", got) } } func TestHTMLEscapesArguments(t *testing.T) { b := load(t) got := b.HTML("en", "start.private", i18n.Args{"Name": ""}) if strings.Contains(got, "