diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:51:40 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 21:51:40 +0200 |
| commit | 4c776396115c8120c3e1cb8fda993449fcdcd326 (patch) | |
| tree | 0144fb325663dde063057a5ec568c59d4cbe79da /internal/cli/cli.go | |
| parent | bfa8df7b36ccbd44703e0705d51a2ed553a23164 (diff) | |
| download | lectio-4c776396115c8120c3e1cb8fda993449fcdcd326.tar.gz lectio-4c776396115c8120c3e1cb8fda993449fcdcd326.zip | |
i18n: ui_language config (default en) for UI chrome across cli/tui/web; version labels localised
Diffstat (limited to 'internal/cli/cli.go')
| -rw-r--r-- | internal/cli/cli.go | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go index e7a2439..b660878 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -14,6 +14,7 @@ import ( "time" "github.com/lukaszkasprzak/lectio/internal/config" + "github.com/lukaszkasprzak/lectio/internal/i18n" "github.com/lukaszkasprzak/lectio/internal/liturgy" "github.com/lukaszkasprzak/lectio/internal/readings" "github.com/lukaszkasprzak/lectio/internal/render" @@ -274,7 +275,7 @@ func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width w := resolveWidth(width, false, stdout) if !raw { - banner := bannerFor(all, date) + banner := bannerFor(cfg.UILanguage, all, date) fmt.Fprintln(stdout, banner) fmt.Fprintln(stdout, strings.Repeat("=", minInt(len(banner), w))) fmt.Fprintln(stdout) @@ -282,33 +283,39 @@ func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width pieces := make([]string, 0, len(secs)) for _, sec := range secs { - pieces = append(pieces, renderSection(sec, version, cfg.Lectionary, w, raw)) + pieces = append(pieces, renderSection(sec, version, cfg.Lectionary, cfg.UILanguage, w, raw)) } fmt.Fprintln(stdout, strings.Join(pieces, "\n\n")) return 0 } -// bannerFor mirrors ewangelia.py's banner text: "Czytania na D" when every -// part is shown, "Ewangelia na D" for the gospel-only default. -func bannerFor(all bool, date string) string { +// bannerFor builds the "<Gospel|Readings> — DATE" banner: the "readings" +// word when every part is shown, "gospel" for the gospel-only default, both +// localised via i18n.Get(lang) (lang="pl" reproduces ewangelia.py's original +// Polish wording, just with "—" in place of "na"). +func bannerFor(lang string, all bool, date string) string { + ui := i18n.Get(lang) + word := ui.BannerGospel if all { - return "Czytania na " + date + word = ui.BannerReadings } - return "Ewangelia na " + date + return word + " — " + date } // renderSection formats one section as its heading (unless raw) followed by -// render.GatherVersion's blocks, each wrapped to width. -func renderSection(sec liturgy.Section, version, lectionary string, width int, raw bool) string { +// render.GatherVersion's blocks, each wrapped to width. The heading's part +// label is localised via render.LocalizeHeading (lang); the citation/verse +// text is never touched. +func renderSection(sec liturgy.Section, version, lectionary, lang string, width int, raw bool) string { var lines []string if !raw { - lines = append(lines, sec.Heading) + lines = append(lines, render.LocalizeHeading(sec.Heading, sec.PartID, lang)) if sec.Subtitle != "" { lines = append(lines, sec.Subtitle) } lines = append(lines, "") } - _, blocks := render.GatherVersion(version, sec, lectionary) + _, blocks := render.GatherVersion(version, sec, lectionary, lang) for _, b := range blocks { lines = append(lines, wrapText(b, width)) } @@ -359,12 +366,12 @@ func renderCompare(cfg config.Config, list, date string, all, raw bool, width in w := resolveWidth(width, true, stdout) if !raw { - banner := bannerFor(all, date) + banner := bannerFor(cfg.UILanguage, all, date) fmt.Fprintln(stdout, banner) fmt.Fprintln(stdout, strings.Repeat("=", minInt(len(banner), w))) fmt.Fprintln(stdout) } - fmt.Fprintln(stdout, render.Compare(secs, versions, w, cfg.Lectionary)) + fmt.Fprintln(stdout, render.Compare(secs, versions, w, cfg.Lectionary, cfg.UILanguage)) return 0 } |
