From 390f8cb146c69d8d3a0e6e0d76ea3546f30a7611 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 23 Jul 2026 22:08:56 +0200 Subject: i18n: fix consistency-review gaps in ui_language (en/pl chrome) Closes six findings from review of the ui_language feature so English mode carries no leftover Polish UI text: - Web: interlinear "no verses" note and the empty-day error fragment now route through i18n instead of being unconditionally Polish. - render.GatherVersion/GatherVerses/resolveRef's four lookup/citation- failure blocks are now lang-aware (resolveRef gained a lang param). - i18n.ErrorPrefix/NoReadingsFor lost a stray extra trailing space, restoring the pre-i18n single-space TUI concatenation. - render.LocalizeHeading now matches a heading's actual leading label text against all known modern pl labels, rather than trusting the label keyed by sec.PartID -- fixes split-feast days where PartID is "drugie_czytanie" but the heading still reads "1. czytanie ...". - cli bannerFor is lang-specific again (pl "na", en "for"), restoring pl's exact pre-i18n wording instead of "--" for both languages. - index.html's now follows cfg.UILanguage instead of being hardcoded "pl". gofmt/vet clean, go test ./... green, all three binaries build, no new go.mod deps. Consistency grep across cli/tui/web/render's live source turns up only two non-displayed identifiers (a PartID slug list and a pre-existing incipit-stripping constant on the pl scripture text itself). --- internal/cli/cli.go | 12 +++++++----- internal/cli/cli_test.go | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'internal/cli') diff --git a/internal/cli/cli.go b/internal/cli/cli.go index b660878..a13f2f1 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -289,17 +289,19 @@ func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width return 0 } -// bannerFor builds the " — DATE" banner: the "readings" -// word when every part is shown, "gospel" for the gospel-only default, both -// localised via i18n.Get(lang) (lang="pl" reproduces ewangelia.py's original -// Polish wording, just with "—" in place of "na"). +// bannerFor builds the " DATE" banner: the +// "readings" word when every part is shown, "gospel" for the gospel-only +// default, and the connective between word and date, all localised via +// i18n.Get(lang) -- lang="pl" reproduces ewangelia.py's original Polish +// wording exactly ("Ewangelia na DATE" / "Czytania na DATE"); lang="en" +// gives "Gospel for DATE" / "Readings for DATE". func bannerFor(lang string, all bool, date string) string { ui := i18n.Get(lang) word := ui.BannerGospel if all { word = ui.BannerReadings } - return word + " — " + date + return word + " " + ui.BannerConnective + " " + date } // renderSection formats one section as its heading (unless raw) followed by diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index de9220a..d0c8791 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -105,6 +105,27 @@ func TestLangBogus(t *testing.T) { } } +// TestBannerForLang checks bannerFor's wording follows lang: pl reproduces +// the pre-i18n Polish banner exactly ("Ewangelia na D" / "Czytania na D"), +// en gives "Gospel for D" / "Readings for D". +func TestBannerForLang(t *testing.T) { + cases := []struct { + lang string + all bool + want string + }{ + {"pl", false, "Ewangelia na 2026-07-22"}, + {"pl", true, "Czytania na 2026-07-22"}, + {"en", false, "Gospel for 2026-07-22"}, + {"en", true, "Readings for 2026-07-22"}, + } + for _, c := range cases { + if got := bannerFor(c.lang, c.all, "2026-07-22"); got != c.want { + t.Errorf("bannerFor(%q, %v, ...) = %q, want %q", c.lang, c.all, got, c.want) + } + } +} + // TestDateTokenAnyPosition exercises extractDate directly: the date token // is found regardless of where it appears among other flags. func TestDateTokenAnyPosition(t *testing.T) { -- cgit v1.3