aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go36
1 files changed, 21 insertions, 15 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 299c942..c9a00f2 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 en | pl (interface chrome; readings stay source-language)
+# ui_language any code (en, pl, ...) (chrome is en/pl, else English; day/saint names from names/<code>.ini)
# 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)
@@ -131,21 +131,14 @@ 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).
+// NormalizeUILanguage lower-cases and trims a ui_language code. Any code is
+// accepted: it selects day- and saint-name localisation (names/<code>.ini, via
+// internal/naming) and, for the UI chrome, resolves through i18n.Get, which
+// falls back to English for anything other than the built-in "en"/"pl". So a
+// user can set ui_language = fr, ship a names/fr.ini, and get French day names
+// with English chrome -- no rebuild.
func NormalizeUILanguage(lang string) string {
- l := strings.ToLower(lang)
- if !validUILanguages[l] {
- return "en"
- }
- return l
+ return strings.ToLower(strings.TrimSpace(lang))
}
// NormalizeSiglaStyle maps a sigla_style setting to one of "auto", "polish",
@@ -354,6 +347,19 @@ func CorporaDir() (string, error) {
return filepath.Join(filepath.Dir(p), "corpora"), nil
}
+// NamesDir is the user directory for drop-in day-name language files
+// (<code>.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;
+// combined with ui_language = <code>, it localises the daily view to any
+// language without a rebuild. Mirrors CalendarsDir/CorporaDir.
+func NamesDir() (string, error) {
+ p, _, err := configPath()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(filepath.Dir(p), "names"), nil
+}
+
// BooksPath returns the path to the optional user books.ini (in the same
// directory as the config file). There is no embedded seed on disk -- absence
// means "use the built-in defaults".