diff options
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 |
