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/config/config.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/config/config.go')
| -rw-r--r-- | internal/config/config.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index e501cf8..dd81544 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -51,6 +51,23 @@ func NormalizeDisplay(display string) string { return d } +// validUILanguages are the two UI chrome languages lectio understands. +var validUILanguages = map[string]bool{ + "en": true, + "pl": true, +} + +// NormalizeUILanguage lower-cases lang and falls back to "en" when it is not +// one of validUILanguages -- the same lenient style as NormalizeDisplay (no +// error, just a safe default). +func NormalizeUILanguage(lang string) string { + l := strings.ToLower(lang) + if !validUILanguages[l] { + return "en" + } + return l +} + // Config holds lectio's user-configurable settings. type Config struct { SchemaVersion int `toml:"schema_version"` @@ -61,6 +78,7 @@ type Config struct { Width int `toml:"width"` All bool `toml:"all"` Offline bool `toml:"offline"` + UILanguage string `toml:"ui_language"` WebTheme string `toml:"web_theme"` WebPort int `toml:"web_port"` WebDisplay string `toml:"web_display"` @@ -91,6 +109,7 @@ func Default() Config { Width: 0, All: false, Offline: false, + UILanguage: "en", WebTheme: "transfiguration", WebPort: 0, WebDisplay: "horizontal", @@ -162,6 +181,7 @@ func Load() (Config, error) { return def, nil } cfg.WebDisplay = NormalizeDisplay(cfg.WebDisplay) + cfg.UILanguage = NormalizeUILanguage(cfg.UILanguage) if err := validate(cfg); err != nil { return Config{}, err |
