summaryrefslogtreecommitdiff
path: root/internal/cli/liturgy.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 20:40:12 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 20:40:12 +0200
commit588d9fb64e023d08b3e6105b69c08d3f9ddf6083 (patch)
treec2144823d288c2d8d4e072ebfb3ecc58455fd192 /internal/cli/liturgy.go
parent2cf3c82d357663423b7f77ec20cdd03faca209fa (diff)
downloadlectio-588d9fb64e023d08b3e6105b69c08d3f9ddf6083.tar.gz
lectio-588d9fb64e023d08b3e6105b69c08d3f9ddf6083.zip
feat(cli): config-driven reading corpus + surface user corpora
Diffstat (limited to 'internal/cli/liturgy.go')
-rw-r--r--internal/cli/liturgy.go41
1 files changed, 29 insertions, 12 deletions
diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go
index bb250a5..ced23ae 100644
--- a/internal/cli/liturgy.go
+++ b/internal/cli/liturgy.go
@@ -61,18 +61,35 @@ func dayReadings(sel calendar.Selection, layers []calendar.Layer, date time.Time
return nil
}
-// vernacularVersion is the COMPLETE offline corpus used to render reading text.
-// The Wujek (wuj) corpus is intentionally NOT auto-selected here: it lacks the
-// deuterocanonical Daniel/Esther additions and ~400 verses its builder dropped,
-// so Polish renders from the complete Latin Vulgate until a properly-formatted
-// Polish Bible is supplied as a user corpus (the national-bibles feature). wuj
-// stays available for explicit `--ref -b wuj` and version comparison. English
-// uses Douay-Rheims (complete after the deuterocanon backfill); bt is scraped.
+// vernacularVersion is the corpus that renders reading text: the config's
+// resolved reading corpus (Config.ReadingCorpus -- an explicit
+// reading_version, else a reading_lang/ui_language match against
+// autoselect-eligible corpora), else the complete Latin Vulgate. The
+// built-in Wujek (wuj) sets autoselect=false in its sidecar (it lacks the
+// deuterocanonical Daniel/Esther additions and ~400 verses its builder
+// dropped), so Polish still falls back to Latin until a properly-formatted
+// Polish Bible is supplied as a user corpus (the national-bibles feature);
+// wuj stays available for explicit `--ref -b wuj` and version comparison.
func vernacularVersion(cfg config.Config) string {
- if cfg.TraditionalLang == "pl" || cfg.UILanguage == "pl" {
- return "vul" // Latin: no complete Polish corpus yet (wuj is defective)
+ if code := cfg.ReadingCorpus(); code != "" {
+ return code
}
- return "drb"
+ return latinFallback // "vul"
+}
+
+// versionDisplayName resolves a corpus code's display label for lang: the
+// localized i18n chrome label (internal/i18n) when lang defines one for
+// code, else the corpus's own sidecar Name (bible.Meta -- covers user and
+// other registered corpora the built-in i18n tables don't know about), else
+// the bare code.
+func versionDisplayName(lang, code string) string {
+ if l, ok := i18n.Get(lang).Version[code]; ok {
+ return l
+ }
+ if m, ok := bible.Meta(code); ok && m.Name != "" {
+ return m.Name
+ }
+ return code
}
// latinFallback is the corpus used to render a passage the vernacular corpus
@@ -138,8 +155,8 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable,
continue
}
if used != vern { // the vernacular lacked it; fell back to Latin
- names := i18n.Get("en").Version
- fmt.Fprintf(out, " [%s has no text here -- showing %s]\n", names[vern], names[used])
+ fmt.Fprintf(out, " [%s has no text here -- showing %s]\n",
+ versionDisplayName("en", vern), versionDisplayName("en", used))
}
for _, line := range strings.Split(render.Wrap(txt, 72), "\n") {
fmt.Fprintf(out, " %s\n", line)