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/web/server.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'internal/web/server.go') diff --git a/internal/web/server.go b/internal/web/server.go index 3b7102c..4c13576 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -188,6 +188,8 @@ type indexData struct { // set from i18n.Get(cfg.UILanguage) -- index.html references its // fields (e.g. {{.L.Lectionary}}) instead of hardcoded Polish text. L i18n.UI + // Lang is cfg.UILanguage, rendered into . + Lang string } type versionOpt struct { @@ -245,6 +247,7 @@ func indexHandler(cfg config.Config) http.HandlerFunc { Mono: queryBool(r, "mono", cfg.WebMono), Reading: reading, L: i18n.Get(cfg.UILanguage), + Lang: cfg.UILanguage, } w.Header().Set("Content-Type", "text/html; charset=utf-8") @@ -269,15 +272,16 @@ func readingsHandler(cfg config.Config) http.HandlerFunc { } // renderOrError returns RenderReadings' fragment, or (on a readings.Load -// error) a small escaped error paragraph -- readings.Load errors are -// expected in normal operation (an unpublished date, no network while -// online, ...) so the pane should show them, not 500. +// error, or no sections at all for the date) a small escaped error +// paragraph, localised via lang -- readings.Load errors are expected in +// normal operation (an unpublished date, no network while online, ...) so +// the pane should show them, not 500. func renderOrError(secs []liturgy.Section, versions []string, lectionary, display, lang string, err error) template.HTML { if err != nil { return template.HTML(`

` + template.HTMLEscapeString(err.Error()) + `

`) } if len(secs) == 0 { - return template.HTML(`

brak czytań na ten dzień

`) + return template.HTML(`

` + template.HTMLEscapeString(i18n.Get(lang).NoReadingsDay) + `

`) } return RenderReadings(secs, versions, lectionary, display, lang) } -- cgit v1.3