From 9100973576f87adcadaf6c8b331df7e729aeb117 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 19:03:15 +0200 Subject: i18n: make all UI chrome user-translatable via ui/.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 /ui/.ini, resolved per key with an English fallback. With ui_language = plus a names/.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/.ini alongside names/.ini. --- internal/config/config.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'internal/config') diff --git a/internal/config/config.go b/internal/config/config.go index c9a00f2..08c0b60 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -37,7 +37,7 @@ const configHeader = `# lectio configuration (INI). Full-line comments only (# o # width integer; 0 = detect terminal width # all true | false (all readings, or just the gospel) # offline true | false (never fetch; cache/sigla only) -# ui_language any code (en, pl, ...) (chrome is en/pl, else English; day/saint names from names/.ini) +# ui_language any code (en, pl, ...) (chrome from ui/.ini, day names from names/.ini; en/pl built in, else English) # reading_lang language for offline reading text (e.g. en, pl); blank follows ui_language # reading_version force a specific bible corpus code (e.g. drb, wuj); blank = auto-resolve # sigla_style auto | polish | english | latin (citation dialect; auto follows ui_language) @@ -347,6 +347,19 @@ func CorporaDir() (string, error) { return filepath.Join(filepath.Dir(p), "corpora"), nil } +// UIDir is the user directory for drop-in UI-chrome language files +// (.ini: button/label/keybar strings), alongside names/, calendars/ and +// corpora/ under the lectio config dir. A file here overrides the built-in +// chrome for its language key by key; with ui_language = it translates +// the whole interface without a rebuild. Mirrors NamesDir. +func UIDir() (string, error) { + p, _, err := configPath() + if err != nil { + return "", err + } + return filepath.Join(filepath.Dir(p), "ui"), nil +} + // NamesDir is the user directory for drop-in day-name language files // (.ini), alongside calendars/ and corpora/ under the lectio config dir. // A file here overrides the built-in day names for its language key by key; -- cgit v1.3