aboutsummaryrefslogtreecommitdiff
path: root/internal/tui/tui.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 21:51:40 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 21:51:40 +0200
commit4c776396115c8120c3e1cb8fda993449fcdcd326 (patch)
tree0144fb325663dde063057a5ec568c59d4cbe79da /internal/tui/tui.go
parentbfa8df7b36ccbd44703e0705d51a2ed553a23164 (diff)
downloadlectio-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/tui/tui.go')
-rw-r--r--internal/tui/tui.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 1e3b948..bcfb3c1 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -13,6 +13,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"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"
@@ -42,8 +43,6 @@ type errMsg struct {
err error
}
-const footerKeys = "tab/⇧tab wersja ←/→ dzień j/k przewiń spacja/b strona g/G góra/dół r odśwież q wyjście"
-
// New builds the initial model: cfg.Offline drops "pl" from the version
// list (render.OfflineVersions), the active version starts at
// cfg.DefaultVersion (falling back to the first version if not found, or
@@ -256,7 +255,7 @@ func (m Model) View() string {
}
header := headerStyle.Width(w).Render(m.headerText())
- footer := footerStyle.Width(w).Render(footerKeys)
+ footer := footerStyle.Width(w).Render(i18n.Get(m.cfg.UILanguage).FooterKeys)
bodyLines := m.bodyLines(innerW)
@@ -276,7 +275,7 @@ func (m Model) View() string {
func (m Model) headerText() string {
label := m.version()
if len(m.sections) > 0 {
- if l, _ := render.GatherVersion(m.version(), m.sections[0], m.cfg.Lectionary); l != "" {
+ if l, _ := render.GatherVersion(m.version(), m.sections[0], m.cfg.Lectionary, m.cfg.UILanguage); l != "" {
label = l
}
}
@@ -287,17 +286,19 @@ func (m Model) headerText() string {
// through: a loading/error/empty notice, or each section's heading +
// render.GatherVersion blocks for the active version.
func (m Model) bodyLines(w int) []string {
+ ui := i18n.Get(m.cfg.UILanguage)
+
switch {
case m.err != nil:
return []string{
- errStyle.Render("błąd: " + m.err.Error()),
+ errStyle.Render(ui.ErrorPrefix + m.err.Error()),
"",
- citationStyle.Render("zmień datę (←/→) lub odśwież (r)"),
+ citationStyle.Render(ui.ErrorHint),
}
case m.loading:
- return []string{citationStyle.Render("ładowanie…")}
+ return []string{citationStyle.Render(ui.Loading)}
case len(m.sections) == 0:
- return []string{citationStyle.Render("brak czytań na " + m.date)}
+ return []string{citationStyle.Render(ui.NoReadingsFor + m.date)}
}
ver := m.version()
@@ -306,13 +307,14 @@ func (m Model) bodyLines(w int) []string {
if i > 0 {
lines = append(lines, "")
}
- lines = append(lines, headingStyle.Render(sec.Heading))
+ heading := render.LocalizeHeading(sec.Heading, sec.PartID, m.cfg.UILanguage)
+ lines = append(lines, headingStyle.Render(heading))
if sec.Subtitle != "" {
lines = append(lines, citationStyle.Render(sec.Subtitle))
}
lines = append(lines, "")
- _, blocks := render.GatherVersion(ver, sec, m.cfg.Lectionary)
+ _, blocks := render.GatherVersion(ver, sec, m.cfg.Lectionary, m.cfg.UILanguage)
isPsalm := sec.PartID == "psalm"
for bi, b := range blocks {
refrain := isPsalm && bi == 0