diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 18:15:29 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 18:15:29 +0200 |
| commit | 539a7c71b60115144959f712ef5966f48c63f9f0 (patch) | |
| tree | 0f07fe348a3a6c99d5a8713e39dd99640aa6efd9 /internal/readings/offline.go | |
| parent | 5e1664b8008675177a551aff1de371f54d4e20e4 (diff) | |
| download | lectio-539a7c71b60115144959f712ef5966f48c63f9f0.tar.gz lectio-539a7c71b60115144959f712ef5966f48c63f9f0.zip | |
naming: localise liturgical day names in any language
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/<code>.ini
(pl shipped) and/or a user file at <config dir>/names/<code>.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.<lang> -> English -> Latin -> humanized slug.
Saint names stay in the calendar data (name.<lang>), overridable via
calendar layers.
- config: ui_language now accepts any code (lower-cased, not clamped to
en/pl) so names/<code>.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.
Diffstat (limited to 'internal/readings/offline.go')
| -rw-r--r-- | internal/readings/offline.go | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/internal/readings/offline.go b/internal/readings/offline.go index 566fc7a..d0b8942 100644 --- a/internal/readings/offline.go +++ b/internal/readings/offline.go @@ -9,6 +9,7 @@ import ( "github.com/lukaszkasprzak/lectio/internal/calendar" "github.com/lukaszkasprzak/lectio/internal/config" "github.com/lukaszkasprzak/lectio/internal/liturgy" + "github.com/lukaszkasprzak/lectio/internal/naming" ) // offlineLoad resolves a day's readings entirely from the embedded calendar @@ -119,22 +120,8 @@ func dayInfo(cfg config.Config, day calendar.LiturgicalDay) liturgy.DayInfo { } // celebrationName is the observed celebration's name in the UI language, -// falling back to English then a humanized slug for temporal days that carry no -// proper name (mirrors the CLI's cli.celebrationName). An empty result omits -// the header line. +// resolved by naming.CelebrationName (name.<lang> -> English -> Latin -> +// humanized slug). An empty result (unnamed feria) omits the header line. 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 != "" { - return n - } - if c.Slug == "" { - return "" - } - return calendar.HumanizeSlug(c.Slug) + return naming.CelebrationName(cfg.UILanguage, c) } |
