summaryrefslogtreecommitdiff
path: root/internal/render/render_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 22:08:56 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 22:08:56 +0200
commit390f8cb146c69d8d3a0e6e0d76ea3546f30a7611 (patch)
tree99510b1fe2d80bfc1ab26473a53def3318bed256 /internal/render/render_test.go
parent4c776396115c8120c3e1cb8fda993449fcdcd326 (diff)
downloadlectio-390f8cb146c69d8d3a0e6e0d76ea3546f30a7611.tar.gz
lectio-390f8cb146c69d8d3a0e6e0d76ea3546f30a7611.zip
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 <html lang> 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).
Diffstat (limited to 'internal/render/render_test.go')
-rw-r--r--internal/render/render_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/internal/render/render_test.go b/internal/render/render_test.go
index b016d6b..affaaf8 100644
--- a/internal/render/render_test.go
+++ b/internal/render/render_test.go
@@ -76,6 +76,56 @@ func TestCompareLabelLang(t *testing.T) {
}
}
+// TestGatherVersionNoVersionLang checks that the "(not in %s)" block
+// (bible.Lookup finding nothing at all) follows lang -- pl reproduces the
+// original Polish wording exactly, en uses internal/i18n's English wording.
+func TestGatherVersionNoVersionLang(t *testing.T) {
+ sec := liturgy.Section{Heading: "Ewangelia (J 20, 1. 11-18)"}
+
+ _, blocks := GatherVersion("zzz", sec, "new", "pl")
+ if len(blocks) == 0 || blocks[0] != `(brak w „zzz”)` {
+ t.Errorf(`GatherVersion(..., "pl") blocks = %v, want [(brak w „zzz”)]`, blocks)
+ }
+
+ _, blocks = GatherVersion("zzz", sec, "new", "en")
+ if len(blocks) == 0 || blocks[0] != "(not in zzz)" {
+ t.Errorf(`GatherVersion(..., "en") blocks = %v, want [(not in zzz)]`, blocks)
+ }
+}
+
+// TestGatherVersionNoReferenceLang checks the "(no reference)" block (no
+// citation resolvable at all) follows lang.
+func TestGatherVersionNoReferenceLang(t *testing.T) {
+ sec := liturgy.Section{Heading: "Bez odwołania"}
+
+ _, blocks := GatherVersion("wuj", sec, "new", "pl")
+ if len(blocks) == 0 || blocks[0] != "(brak odwołania)" {
+ t.Errorf(`GatherVersion(..., "pl") blocks = %v, want [(brak odwołania)]`, blocks)
+ }
+
+ _, blocks = GatherVersion("wuj", sec, "new", "en")
+ if len(blocks) == 0 || blocks[0] != "(no reference)" {
+ t.Errorf(`GatherVersion(..., "en") blocks = %v, want [(no reference)]`, blocks)
+ }
+}
+
+// TestGatherVersionNoReferenceErrLang checks the "(no reference: ...)" block
+// (a citation that bible.ToEnglishRef fails to convert, e.g. an unrecognised
+// book) follows lang.
+func TestGatherVersionNoReferenceErrLang(t *testing.T) {
+ sec := liturgy.Section{Citation: "Xyz 1, 1-2"}
+
+ _, blocks := GatherVersion("wuj", sec, "new", "pl")
+ if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "(brak odwołania: ") {
+ t.Errorf(`GatherVersion(..., "pl") blocks = %v, want prefix "(brak odwołania: "`, blocks)
+ }
+
+ _, blocks = GatherVersion("wuj", sec, "new", "en")
+ if len(blocks) == 0 || !strings.HasPrefix(blocks[0], "(no reference: ") {
+ t.Errorf(`GatherVersion(..., "en") blocks = %v, want prefix "(no reference: "`, blocks)
+ }
+}
+
func TestOfflineVersions(t *testing.T) {
got := OfflineVersions([]string{"pl", "wuj", "vul"})
for _, v := range got {
@@ -143,6 +193,12 @@ func TestLocalizeHeading(t *testing.T) {
{"unknown partID unchanged", "Coś innego (X 1)", "", "en", "Coś innego (X 1)"},
{"already-English heading unchanged (traditional lectionary, no pl prefix to match)", "Gospel (Luke 7:36-50)", "ewangelia", "en", "Gospel (Luke 7:36-50)"},
{"prefix mismatch unchanged", "Nieoczekiwany tytuł (J 1)", "ewangelia", "en", "Nieoczekiwany tytuł (J 1)"},
+ // Split (two-reading) feast day: niedziela.pl scrapes
+ // PartID="drugie_czytanie" onto a heading that still literally
+ // starts with "1. czytanie" (its own numbering quirk). Matching
+ // must follow the heading's actual text, not partID's label, so
+ // this localises to "1st reading", not staying Polish.
+ {"drugie_czytanie partID with a 1. czytanie heading (split feast day)", "1. czytanie (Dz 2, 14. 22-33)", "drugie_czytanie", "en", "1st reading (Dz 2, 14. 22-33)"},
}
for _, c := range cases {