diff options
Diffstat (limited to 'internal/cli/liturgy.go')
| -rw-r--r-- | internal/cli/liturgy.go | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go index af58a34..9dcdb69 100644 --- a/internal/cli/liturgy.go +++ b/internal/cli/liturgy.go @@ -10,6 +10,7 @@ import ( "github.com/lukaszkasprzak/lectio/internal/caldata" "github.com/lukaszkasprzak/lectio/internal/calendar" "github.com/lukaszkasprzak/lectio/internal/config" + "github.com/lukaszkasprzak/lectio/internal/i18n" "github.com/lukaszkasprzak/lectio/internal/render" ) @@ -69,23 +70,44 @@ func vernacularVersion(cfg config.Config) string { return "drb" } -// readingLine resolves an English-authored citation and returns (display, -// text): display is the citation re-formatted in the user's configured sigla -// dialect (SiglaLang); text is the verses from version (or "" if unresolved). -// The reading data is authored in English, so it is parsed in the "en" dialect; -// only the display honors the configured dialect's abbreviations. -func readingLine(tbl *bible.BookTable, cfg config.Config, version, citation string) (string, string) { +// latinFallback is the corpus used to render a passage the vernacular corpus +// lacks: the Latin Vulgate, which carries the full canon -- including the +// deuterocanonical Daniel (13-14) and Esther (11-16) additions the vernacular +// corpora omit and which the EF Lenten lectionary reads. The EF is a Latin +// rite, so the Latin is the authoritative text to fall back to. +const latinFallback = "vul" + +// readingLine resolves an English-authored citation and returns (display, text, +// used): display is the citation re-formatted in the user's configured sigla +// dialect (SiglaLang); text is the verses; used is the version that actually +// supplied the text -- version, else latinFallback, else "" when neither has +// it. The reading data is authored in English, so it is parsed in the "en" +// dialect; only the display honors the configured dialect's abbreviations. +func readingLine(tbl *bible.BookTable, cfg config.Config, version, citation string) (display, text, used string) { engRef, ok := tbl.ParseRef("en", citation) if !ok { - return citation, "" // unparseable: show as authored + return citation, "", "" // unparseable: show as authored + } + display = tbl.FormatRef(cfg.SiglaLang(), engRef) + if txt := lookupText(version, engRef); txt != "" { + return display, txt, version + } + if version != latinFallback { + if txt := lookupText(latinFallback, engRef); txt != "" { + return display, txt, latinFallback + } } - display := tbl.FormatRef(cfg.SiglaLang(), engRef) - vs, _ := bible.Lookup(version, engRef) + return display, "", "" +} + +// lookupText joins the verses of ref in version into one string ("" if none). +func lookupText(version, ref string) string { + vs, _ := bible.Lookup(version, ref) parts := make([]string, 0, len(vs)) for _, v := range vs { parts = append(parts, strings.TrimSpace(v.Text)) } - return display, strings.Join(parts, " ") + return strings.Join(parts, " ") } func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, day calendar.LiturgicalDay, readings []calendar.Reading) { @@ -104,14 +126,18 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, } vern := vernacularVersion(cfg) for _, r := range readings { - disp, txt := readingLine(tbl, cfg, vern, r.Citation) + disp, txt, used := readingLine(tbl, cfg, vern, r.Citation) fmt.Fprintf(out, "\n %s (%s):\n", r.Part, disp) - if txt != "" { - for _, line := range strings.Split(render.Wrap(txt, 72), "\n") { - fmt.Fprintf(out, " %s\n", line) - } - } else { + if txt == "" { fmt.Fprintf(out, " (text not in %s)\n", vern) + 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]) + } + for _, line := range strings.Split(render.Wrap(txt, 72), "\n") { + fmt.Fprintf(out, " %s\n", line) } } } |
