From da1818a73de736dffd1580137352c32bea81be8c Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 3 Aug 2026 23:34:22 +0200 Subject: i18n: rank and colour vocabulary tables --- internal/i18n/i18n.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'internal/i18n/i18n.go') diff --git a/internal/i18n/i18n.go b/internal/i18n/i18n.go index fece4a8..3928da8 100644 --- a/internal/i18n/i18n.go +++ b/internal/i18n/i18n.go @@ -15,14 +15,27 @@ type UI struct { // version code (wuj, vul, grb, drb). Version map[string]string - // PartLabel names each modern-lectionary section's heading label word, - // keyed by liturgy.Section.PartID (pierwsze_czytanie, psalm, + // PartLabel names each lectionary section's heading label word, keyed by + // liturgy.Section.PartID -- the modern IDs (pierwsze_czytanie, psalm, // drugie_czytanie, aklamacja, ewangelia). The pl entries are the exact // prefixes niedziela.pl's scraped headings carry, used by // render.LocalizeHeading to recognise and swap the label word while // keeping the citation untouched. PartLabel map[string]string + // Rank names each liturgical rank, keyed by the string form of + // calendar.Rank. Two vocabularies share the map: the Ordinary Form's + // ferial/optional/memorial/feast/solemnity and the 1962 form's + // class-1..class-4/commemoration. Rendered by the CLI's day header and + // by the dlectio app's day banner and calendar rows. + Rank map[string]string + + // Colour names each normalized liturgical colour, keyed by the string form + // of calendar.Colour (white, red, green, violet, rose, black). Rendered by + // the CLI's day header only -- the dlectio app draws a coloured swatch + // instead and deliberately shows no colour word. + Colour map[string]string + // TUI keybar and status messages. NoReadingsFor and ErrorPrefix each // carry their own single trailing space (the TUI concatenates a date or // error string directly onto them, no separator added at the call site). -- cgit v1.3 From 14c4540d3f06299bf65d74ea864ae7c6c4c33f72 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 3 Aug 2026 23:39:49 +0200 Subject: i18n: drop the colour word table, it has no consumer --- internal/i18n/golden_test.go | 8 -------- internal/i18n/i18n.go | 6 ------ internal/i18n/lang/en.ini | 6 ------ internal/i18n/lang/pl.ini | 6 ------ internal/i18n/vocab_test.go | 11 +---------- 5 files changed, 1 insertion(+), 36 deletions(-) (limited to 'internal/i18n/i18n.go') diff --git a/internal/i18n/golden_test.go b/internal/i18n/golden_test.go index b3ad125..d07d20a 100644 --- a/internal/i18n/golden_test.go +++ b/internal/i18n/golden_test.go @@ -30,10 +30,6 @@ var enUI = UI{ "class-3": "III class", "class-4": "IV class", "commemoration": "commemoration", }, - Colour: map[string]string{ - "white": "white", "red": "red", "green": "green", - "violet": "violet", "rose": "rose", "black": "black", - }, FooterKeys: "tab/⇧tab version ←/→ day d date j/k scroll space/b page g/G top/bottom q quit", Loading: "loading…", NoReadingsFor: "no readings for ", @@ -130,10 +126,6 @@ var plUI = UI{ "class-3": "III klasy", "class-4": "IV klasy", "commemoration": "komemoracja", }, - Colour: map[string]string{ - "white": "biały", "red": "czerwony", "green": "zielony", - "violet": "fioletowy", "rose": "różowy", "black": "czarny", - }, FooterKeys: "tab/⇧tab wersja ←/→ dzień d data j/k przewiń spacja/b strona g/G góra/dół q wyjście", Loading: "ładowanie…", NoReadingsFor: "brak czytań na ", diff --git a/internal/i18n/i18n.go b/internal/i18n/i18n.go index 3928da8..356cc66 100644 --- a/internal/i18n/i18n.go +++ b/internal/i18n/i18n.go @@ -30,12 +30,6 @@ type UI struct { // by the dlectio app's day banner and calendar rows. Rank map[string]string - // Colour names each normalized liturgical colour, keyed by the string form - // of calendar.Colour (white, red, green, violet, rose, black). Rendered by - // the CLI's day header only -- the dlectio app draws a coloured swatch - // instead and deliberately shows no colour word. - Colour map[string]string - // TUI keybar and status messages. NoReadingsFor and ErrorPrefix each // carry their own single trailing space (the TUI concatenates a date or // error string directly onto them, no separator added at the call site). diff --git a/internal/i18n/lang/en.ini b/internal/i18n/lang/en.ini index 12adf7c..a2b53f3 100644 --- a/internal/i18n/lang/en.ini +++ b/internal/i18n/lang/en.ini @@ -17,12 +17,6 @@ rank.ferial = feria rank.memorial = memorial rank.optional = optional memorial rank.solemnity = solemnity -colour.black = black -colour.green = green -colour.red = red -colour.rose = rose -colour.violet = violet -colour.white = white footer_keys = tab/⇧tab version ←/→ day d date j/k scroll space/b page g/G top/bottom q quit loading = loading… no_readings_for = "no readings for " diff --git a/internal/i18n/lang/pl.ini b/internal/i18n/lang/pl.ini index 3521718..d1817f9 100644 --- a/internal/i18n/lang/pl.ini +++ b/internal/i18n/lang/pl.ini @@ -17,12 +17,6 @@ rank.ferial = dzień powszedni rank.memorial = wspomnienie obowiązkowe rank.optional = wspomnienie dowolne rank.solemnity = uroczystość -colour.black = czarny -colour.green = zielony -colour.red = czerwony -colour.rose = różowy -colour.violet = fioletowy -colour.white = biały footer_keys = tab/⇧tab wersja ←/→ dzień d data j/k przewiń spacja/b strona g/G góra/dół q wyjście loading = ładowanie… no_readings_for = "brak czytań na " diff --git a/internal/i18n/vocab_test.go b/internal/i18n/vocab_test.go index 73115bb..d25533a 100644 --- a/internal/i18n/vocab_test.go +++ b/internal/i18n/vocab_test.go @@ -6,7 +6,7 @@ import ( "github.com/lukaszkasprzak/lectio/internal/calendar" ) -// Every rank and colour the calendar can emit must have a word in every shipped +// Every rank the calendar can emit must have a word in every shipped // language. This is the guard against adding a constant later and silently // rendering a raw key like "class-2" in the UI. func TestVocabularyCoversEveryConstant(t *testing.T) { @@ -16,10 +16,6 @@ func TestVocabularyCoversEveryConstant(t *testing.T) { calendar.RankClass1, calendar.RankClass2, calendar.RankClass3, calendar.RankClass4, calendar.RankCommemoration, } - colours := []calendar.Colour{ - calendar.White, calendar.Red, calendar.Green, - calendar.Violet, calendar.Rose, calendar.Black, - } for _, lang := range []string{"en", "pl"} { ui := Get(lang) for _, r := range ranks { @@ -27,11 +23,6 @@ func TestVocabularyCoversEveryConstant(t *testing.T) { t.Errorf("%s: no rank word for %q", lang, r) } } - for _, c := range colours { - if ui.Colour[string(c)] == "" { - t.Errorf("%s: no colour word for %q", lang, c) - } - } } } -- cgit v1.3 From f94ceaae997bce2168a5ab9e64a0c3afeafe0cf6 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 3 Aug 2026 23:50:26 +0200 Subject: i18n: correct rank doc comments and pin the Polish wording --- internal/i18n/i18n.go | 7 +++++-- internal/i18n/vocab_test.go | 22 ++++++++++++++++++++++ internal/liturgy/section.go | 6 +++++- internal/readings/offline.go | 7 ++++--- 4 files changed, 36 insertions(+), 6 deletions(-) (limited to 'internal/i18n/i18n.go') diff --git a/internal/i18n/i18n.go b/internal/i18n/i18n.go index 356cc66..6785705 100644 --- a/internal/i18n/i18n.go +++ b/internal/i18n/i18n.go @@ -26,8 +26,11 @@ type UI struct { // Rank names each liturgical rank, keyed by the string form of // calendar.Rank. Two vocabularies share the map: the Ordinary Form's // ferial/optional/memorial/feast/solemnity and the 1962 form's - // class-1..class-4/commemoration. Rendered by the CLI's day header and - // by the dlectio app's day banner and calendar rows. + // class-1..class-4/commemoration. The English values are hand-synced to + // agree with internal/cli/liturgy.go's own rankLabel() switch, but the + // CLI does not read this map -- it renders rank independently, and the + // two are kept in sync by hand. The actual consumers of this map are the + // dlectio app's day banner and calendar rows. Rank map[string]string // TUI keybar and status messages. NoReadingsFor and ErrorPrefix each diff --git a/internal/i18n/vocab_test.go b/internal/i18n/vocab_test.go index d25533a..bcd3464 100644 --- a/internal/i18n/vocab_test.go +++ b/internal/i18n/vocab_test.go @@ -43,3 +43,25 @@ func TestEnglishRankWordingUnchanged(t *testing.T) { } } } + +// The Polish rank words must be exactly this spelling, diacritics included: +// TestVocabularyCoversEveryConstant only checks non-emptiness, so a typo +// (e.g. "uroczystosc" for "uroczystość", or a wrong diacritic) would pass +// silently without this pin. Polish correctness is the whole point of this +// project. +func TestPolishRankWordingUnchanged(t *testing.T) { + want := map[string]string{ + "solemnity": "uroczystość", "feast": "święto", + "memorial": "wspomnienie obowiązkowe", "optional": "wspomnienie dowolne", + "ferial": "dzień powszedni", + "class-1": "I klasy", "class-2": "II klasy", + "class-3": "III klasy", "class-4": "IV klasy", + "commemoration": "komemoracja", + } + ui := Get("pl") + for k, v := range want { + if got := ui.Rank[k]; got != v { + t.Errorf("rank[%q] = %q, want %q", k, got, v) + } + } +} diff --git a/internal/liturgy/section.go b/internal/liturgy/section.go index 485a45f..baf2b9d 100644 --- a/internal/liturgy/section.go +++ b/internal/liturgy/section.go @@ -36,6 +36,10 @@ type DayInfo struct { // Rank is the normalized liturgical rank of the observed celebration: // the Ordinary Form's "ferial", "optional", "memorial", "feast", // "solemnity", or the 1962 form's "class-1".."class-4", - // "commemoration". Empty when the day carries no rank. + // "commemoration". The engine always supplies a rank: an unset or + // unrecognised rank on a sanctoral celebration defaults to "ferial" + // (calendar.buildCelebration), and every temporal-day constructor sets + // one explicitly. Consumers must not treat an empty Rank as meaning "no + // celebration". Rank string } diff --git a/internal/readings/offline.go b/internal/readings/offline.go index 2f96c14..59a03fa 100644 --- a/internal/readings/offline.go +++ b/internal/readings/offline.go @@ -109,9 +109,10 @@ func sectionsFor(rs []calendar.Reading, form, lang, siglaLang string, tbl *bible return out } -// dayInfo builds the header (celebration name, liturgical colour) for the -// computed day. Season is left empty: the celebration name already carries the -// temporal identity for temporal days, and the header is a nice-to-have. +// dayInfo builds the header (celebration name, liturgical colour, rank) for +// the computed day. Season is left empty: the celebration name already +// carries the temporal identity for temporal days, and the header is a +// nice-to-have. func dayInfo(cfg config.Config, day calendar.LiturgicalDay) liturgy.DayInfo { return liturgy.DayInfo{ Name: celebrationName(cfg, day.Observed), -- cgit v1.3