diff options
Diffstat (limited to 'internal/i18n/i18n_test.go')
| -rw-r--r-- | internal/i18n/i18n_test.go | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/internal/i18n/i18n_test.go b/internal/i18n/i18n_test.go index 8c6f137..59771a8 100644 --- a/internal/i18n/i18n_test.go +++ b/internal/i18n/i18n_test.go @@ -1,6 +1,9 @@ package i18n -import "testing" +import ( + "strings" + "testing" +) func TestGetTheme(t *testing.T) { if got := Get("pl").Theme; got != "motyw" { @@ -56,12 +59,21 @@ func TestTUIStrings(t *testing.T) { if en.Loading != "loading…" || pl.Loading != "ładowanie…" { t.Errorf("Loading en=%q pl=%q", en.Loading, pl.Loading) } - if en.NoReadingsFor != "no readings for " || pl.NoReadingsFor != "brak czytań na " { + if en.NoReadingsFor != "no readings for " || pl.NoReadingsFor != "brak czytań na " { t.Errorf("NoReadingsFor en=%q pl=%q", en.NoReadingsFor, pl.NoReadingsFor) } - if en.ErrorPrefix != "error: " || pl.ErrorPrefix != "błąd: " { + if en.ErrorPrefix != "error: " || pl.ErrorPrefix != "błąd: " { t.Errorf("ErrorPrefix en=%q pl=%q", en.ErrorPrefix, pl.ErrorPrefix) } + // Both carry exactly one trailing space: the TUI concatenates a date or + // error string directly onto them with no separator of its own (see + // internal/tui bodyLines: ui.NoReadingsFor+m.date, ui.ErrorPrefix+err). + if strings.HasSuffix(en.NoReadingsFor, " ") || strings.HasSuffix(pl.NoReadingsFor, " ") { + t.Errorf("NoReadingsFor has 2+ trailing spaces: en=%q pl=%q", en.NoReadingsFor, pl.NoReadingsFor) + } + if strings.HasSuffix(en.ErrorPrefix, " ") || strings.HasSuffix(pl.ErrorPrefix, " ") { + t.Errorf("ErrorPrefix has 2+ trailing spaces: en=%q pl=%q", en.ErrorPrefix, pl.ErrorPrefix) + } if en.ErrorHint != "change date (←/→) or refresh (r)" || pl.ErrorHint != "zmień datę (←/→) lub odśwież (r)" { t.Errorf("ErrorHint en=%q pl=%q", en.ErrorHint, pl.ErrorHint) } @@ -76,6 +88,60 @@ func TestBannerWords(t *testing.T) { if en.BannerReadings != "Readings" || pl.BannerReadings != "Czytania" { t.Errorf("BannerReadings en=%q pl=%q", en.BannerReadings, pl.BannerReadings) } + if en.BannerConnective != "for" || pl.BannerConnective != "na" { + t.Errorf("BannerConnective en=%q pl=%q", en.BannerConnective, pl.BannerConnective) + } +} + +// TestWebFragmentMessages covers the two web-only messages (interlinear +// "no verses" note, "no readings at all for this day" error fragment) that +// were unconditionally Polish before this fix. +func TestWebFragmentMessages(t *testing.T) { + en := Get("en") + pl := Get("pl") + if en.NoInterlinearVerses != "(no verses to align)" { + t.Errorf("en.NoInterlinearVerses = %q", en.NoInterlinearVerses) + } + if pl.NoInterlinearVerses != "(brak wersetów do zestawienia interlinearnego)" { + t.Errorf("pl.NoInterlinearVerses = %q", pl.NoInterlinearVerses) + } + if en.NoReadingsDay != "no readings for this day" { + t.Errorf("en.NoReadingsDay = %q", en.NoReadingsDay) + } + if pl.NoReadingsDay != "brak czytań na ten dzień" { + t.Errorf("pl.NoReadingsDay = %q", pl.NoReadingsDay) + } +} + +// TestLookupFailureMessages covers render.GatherVersion/GatherVerses/ +// resolveRef's four lookup/citation-failure templates. +func TestLookupFailureMessages(t *testing.T) { + en := Get("en") + pl := Get("pl") + + cases := []struct { + name, en, pl string + }{ + {"NoVersion", en.NoVersion, pl.NoVersion}, + {"NoVersionPartial", en.NoVersionPartial, pl.NoVersionPartial}, + {"NoReference", en.NoReference, pl.NoReference}, + {"NoReferenceErr", en.NoReferenceErr, pl.NoReferenceErr}, + } + want := map[string][2]string{ + "NoVersion": {"(not in %s)", "(brak w „%s”)"}, + "NoVersionPartial": {"(not in %s: %s)", "(brak w „%s”: %s)"}, + "NoReference": {"(no reference)", "(brak odwołania)"}, + "NoReferenceErr": {"(no reference: %v)", "(brak odwołania: %w)"}, + } + for _, c := range cases { + w := want[c.name] + if c.en != w[0] { + t.Errorf("en.%s = %q, want %q", c.name, c.en, w[0]) + } + if c.pl != w[1] { + t.Errorf("pl.%s = %q, want %q", c.name, c.pl, w[1]) + } + } } func TestWebControlLabels(t *testing.T) { |
