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/calfeed/build.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'internal/calfeed') diff --git a/internal/calfeed/build.go b/internal/calfeed/build.go index 216daff..8b4f7f0 100644 --- a/internal/calfeed/build.go +++ b/internal/calfeed/build.go @@ -4,6 +4,7 @@ import ( "time" "github.com/lukaszkasprzak/lectio/internal/calendar" + "github.com/lukaszkasprzak/lectio/internal/naming" ) // Build computes the day list from..to inclusive (calendar.Compute per date) @@ -49,19 +50,12 @@ func celView(uiLang string, c calendar.Celebration) CelView { } } -// celebrationName resolves c's name in uiLang, falling back to English, then -// a humanized slug (with the "ef-" prefix stripped and dashes turned to -// spaces), then "(feria)" for an unnamed temporal day. Mirrors -// cli.celebrationName. +// celebrationName resolves c's name in uiLang via naming.CelebrationName +// (name. -> English -> Latin -> humanized slug), then "(feria)" for an +// unnamed temporal day. func celebrationName(uiLang string, c calendar.Celebration) string { - if n := c.Name[uiLang]; n != "" { + if n := naming.CelebrationName(uiLang, c); n != "" { return n } - if n := c.Name["en"]; n != "" { - return n - } - if c.Slug == "" { - return "(feria)" - } - return calendar.HumanizeSlug(c.Slug) + return "(feria)" } -- cgit v1.3