aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 19:03:15 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 19:03:15 +0200
commit9100973576f87adcadaf6c8b331df7e729aeb117 (patch)
treeb67377705bb50c30004c52abc423573d1b335ca8 /cmd
parent771ec96f07499d6efbcb587f94e30ffcbc4e0e58 (diff)
downloadlectio-9100973576f87adcadaf6c8b331df7e729aeb117.tar.gz
lectio-9100973576f87adcadaf6c8b331df7e729aeb117.zip
i18n: make all UI chrome user-translatable via ui/<code>.ini
The interface chrome (version labels, TUI keybar/messages, CLI banner words, web control labels, section-heading words) was English/Polish hardcoded in Go. It is now data: the English and Polish tables ship as embedded lang/en.ini and lang/pl.ini, and any language is user-overridable at <config>/ui/<code>.ini, resolved per key with an English fallback. With ui_language = <code> plus a names/<code>.ini, the WHOLE interface -- chrome, day names, saint names -- is translatable without a rebuild. - i18n.Get loads the embedded English baseline, overlays the embedded/user language file, caches per lang; field <-> INI-key mapping is by reflection (lang.go) so the tables and files stay in sync automatically. Edge-space values (e.g. "error: ") are double-quoted so the INI trim keeps them. The Go tables move to golden_test.go; TestGoldenMatchesEmbedded asserts the embedded files still parse back to them, and TestGenerateLangFiles regenerates them (LECTIO_GEN=1). - config.UIDir(); wire i18n.SetUserDir in the CLI, TUI and web entry points. - README/config: document ui/<code>.ini alongside names/<code>.ini.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/lectio-ui/main.go4
-rw-r--r--cmd/lectio-web/main.go4
2 files changed, 8 insertions, 0 deletions
diff --git a/cmd/lectio-ui/main.go b/cmd/lectio-ui/main.go
index 1b995a4..ad3d4b5 100644
--- a/cmd/lectio-ui/main.go
+++ b/cmd/lectio-ui/main.go
@@ -13,6 +13,7 @@ import (
"github.com/lukaszkasprzak/lectio/internal/bible"
"github.com/lukaszkasprzak/lectio/internal/bookmarks"
"github.com/lukaszkasprzak/lectio/internal/config"
+ "github.com/lukaszkasprzak/lectio/internal/i18n"
"github.com/lukaszkasprzak/lectio/internal/naming"
"github.com/lukaszkasprzak/lectio/internal/tui"
)
@@ -71,6 +72,9 @@ func run(args []string, stdout, stderr io.Writer) int {
if dir, err := config.NamesDir(); err == nil {
naming.SetUserDir(dir)
}
+ if dir, err := config.UIDir(); err == nil {
+ i18n.SetUserDir(dir)
+ }
var all, offline, reader bool
var bibleVer, lectionary string
diff --git a/cmd/lectio-web/main.go b/cmd/lectio-web/main.go
index 683fabe..59ea1e7 100644
--- a/cmd/lectio-web/main.go
+++ b/cmd/lectio-web/main.go
@@ -9,6 +9,7 @@ import (
"github.com/lukaszkasprzak/lectio/internal/bible"
"github.com/lukaszkasprzak/lectio/internal/config"
+ "github.com/lukaszkasprzak/lectio/internal/i18n"
"github.com/lukaszkasprzak/lectio/internal/naming"
"github.com/lukaszkasprzak/lectio/internal/web"
)
@@ -56,6 +57,9 @@ func run(args []string, stdout, stderr io.Writer) int {
if dir, err := config.NamesDir(); err == nil {
naming.SetUserDir(dir)
}
+ if dir, err := config.UIDir(); err == nil {
+ i18n.SetUserDir(dir)
+ }
var offline bool
var port int