From cb3379f41c06a94085c77fe359709b46712850dc Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 14:59:14 +0200 Subject: feat: books.toml -> books.ini, multi-language (add Latin dialect), config-scoped citation display books.ini with [en]/[pl]/[la]; parseBooks reads INI (bible drops go-toml). Latin dialect resolves EF citations (Eccli->Sirach, Apoc->Revelation, Luc...); sigla_style gains 'latin'. Reading citations now DISPLAY in the configured sigla (FormatRef(SiglaLang)), not raw English. One-shot books.toml->books.ini user migration (go-toml now config-only). Web settings editor -> books.ini. --- internal/cli/cli.go | 16 +++------------- internal/cli/liturgy.go | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'internal/cli') diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 575fba9..65be274 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -227,7 +227,7 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { } if citation || week || randV || randCh { - tbl, _ := bible.LoadBookTable(userBooksTOML()) + tbl, _ := bible.LoadBookTable(userBooksINI()) switch { case randV || randCh: ver, verr := randVersion(cfg, bibleVer) @@ -300,7 +300,7 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { var bookTbl *bible.BookTable if list || ref != "" { - tbl, terr := bible.LoadBookTable(userBooksTOML()) + tbl, terr := bible.LoadBookTable(userBooksINI()) if terr != nil { fmt.Fprintln(stderr, "lectio:", terr) // warn; tbl is still a usable defaults table } @@ -516,17 +516,7 @@ func runWeek(cfg config.Config, tbl *bible.BookTable, date string, refresh bool, // userBooksTOML returns the bytes of the optional user books.toml, or nil if // it is absent/unreadable (built-in defaults are used). -func userBooksTOML() []byte { - p, err := config.BooksPath() - if err != nil { - return nil - } - b, err := os.ReadFile(p) - if err != nil { - return nil - } - return b -} +func userBooksINI() []byte { return config.UserBooksINI() } // wantsHelp reports whether -h/--help appears anywhere in args. func wantsHelp(args []string) bool { diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go index fc3efae..840e9a6 100644 --- a/internal/cli/liturgy.go +++ b/internal/cli/liturgy.go @@ -31,7 +31,7 @@ func runLiturgy(cfg config.Config, date string, stdout, stderr io.Writer) int { fmt.Fprintln(stderr, "lectio: warning:", e) } day := calendar.Compute(d.UTC(), cfg.Selection(), layers) - tbl, _ := bible.LoadBookTable(userBooksTOML()) + tbl, _ := bible.LoadBookTable(userBooksINI()) printLiturgicalDay(stdout, cfg, tbl, day) return 0 } @@ -45,19 +45,23 @@ func vernacularVersion(cfg config.Config) string { return "drb" } -// readingText resolves an English citation and returns its text from version, -// or "" if it does not resolve. -func readingText(tbl *bible.BookTable, version, citation string) string { +// 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) { engRef, ok := tbl.ParseRef("en", citation) if !ok { - return "" + return citation, "" // unparseable: show as authored } + display := tbl.FormatRef(cfg.SiglaLang(), engRef) vs, _ := bible.Lookup(version, engRef) parts := make([]string, 0, len(vs)) for _, v := range vs { parts = append(parts, strings.TrimSpace(v.Text)) } - return strings.Join(parts, " ") + return display, strings.Join(parts, " ") } func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, day calendar.LiturgicalDay) { @@ -81,8 +85,9 @@ func printLiturgicalDay(out io.Writer, cfg config.Config, tbl *bible.BookTable, if m.Variant != "" { label = m.Variant + " " + label } - fmt.Fprintf(out, "\n %s (%s):\n", label, r.Citation) - if txt := readingText(tbl, vern, r.Citation); txt != "" { + disp, txt := readingLine(tbl, cfg, vern, r.Citation) + fmt.Fprintf(out, "\n %s (%s):\n", label, disp) + if txt != "" { for _, line := range strings.Split(render.Wrap(txt, 72), "\n") { fmt.Fprintf(out, " %s\n", line) } -- cgit v1.3