From 539a7c71b60115144959f712ef5966f48c63f9f0 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 18:15:29 +0200 Subject: naming: localise liturgical day names in any language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add internal/naming, which renders temporal day names and celebration display names from the calendar engine's slugs in any language. English is the built-in baseline; a language is data -- an embedded lang/.ini (pl shipped) and/or a user file at /names/.ini that overrides it key by key. Names compose from a small vocabulary plus per-language format templates, so word order and grammatical case can differ (e.g. Polish genitive "3. Niedziela Okresu Zwykłego"); any string a language omits falls back to English. - Move day-name generation out of calendar (calendar.HumanizeSlug removed, calendar stays a pure engine) into naming.DayName; the English golden cases carry over verbatim. - naming.CelebrationName unifies the three duplicated resolvers (cli/readings/calfeed): name. -> English -> Latin -> humanized slug. Saint names stay in the calendar data (name.), overridable via calendar layers. - config: ui_language now accepts any code (lower-cased, not clamped to en/pl) so names/.ini applies; UI chrome still resolves en/pl and falls back to English. Add NamesDir(); wire naming.SetUserDir (and the previously unwired bible.SetUserCorporaDir) in the TUI and web mains too, so external corpora and name files work across all three binaries. --- internal/cli/cli.go | 4 ++++ internal/cli/liturgy.go | 20 ++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'internal/cli') diff --git a/internal/cli/cli.go b/internal/cli/cli.go index c4f063d..1fc7ac0 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -19,6 +19,7 @@ import ( "github.com/lukaszkasprzak/lectio/internal/export" "github.com/lukaszkasprzak/lectio/internal/i18n" "github.com/lukaszkasprzak/lectio/internal/liturgy" + "github.com/lukaszkasprzak/lectio/internal/naming" "github.com/lukaszkasprzak/lectio/internal/readings" "github.com/lukaszkasprzak/lectio/internal/render" ) @@ -203,6 +204,9 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { if dir, err := config.CorporaDir(); err == nil { bible.SetUserCorporaDir(dir) } + if dir, err := config.NamesDir(); err == nil { + naming.SetUserDir(dir) + } if lectionary != "" { cfg.Lectionary = lectionary } diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go index 07a87bc..9d7f3b6 100644 --- a/internal/cli/liturgy.go +++ b/internal/cli/liturgy.go @@ -11,6 +11,7 @@ import ( "github.com/lukaszkasprzak/lectio/internal/calendar" "github.com/lukaszkasprzak/lectio/internal/config" "github.com/lukaszkasprzak/lectio/internal/i18n" + "github.com/lukaszkasprzak/lectio/internal/naming" "github.com/lukaszkasprzak/lectio/internal/render" ) @@ -149,23 +150,14 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, } } -// celebrationName is the celebration's name in the UI language (falling back to -// English, then a humanized slug for temporal days that carry no proper name). +// celebrationName is the celebration's name in the UI language, resolved by +// naming.CelebrationName (name. -> English -> Latin -> humanized slug). +// A bare, unnamed feria renders as "(feria)". func celebrationName(cfg config.Config, c calendar.Celebration) string { - lang := "en" - if cfg.UILanguage == "pl" { - lang = "pl" - } - if n := c.Name[lang]; n != "" { - return n - } - if n := c.Name["en"]; n != "" { + if n := naming.CelebrationName(cfg.UILanguage, c); n != "" { return n } - if c.Slug == "" { - return "(feria)" - } - return calendar.HumanizeSlug(c.Slug) + return "(feria)" } func rankLabel(r calendar.Rank) string { -- cgit v1.3