From 42636312160892d1bc6a7f021ce27354f7cbb80d Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 20:19:00 +0200 Subject: feat(config): reading_lang/reading_version + ReadingCorpus resolver Task 3 of national-bibles. Adds reading_lang (any language code) and reading_version (explicit corpus code) config fields, setField cases, renderConfigINI lines + self-documenting header, and Config.ReadingCorpus(): reading_version > reading_lang match > ui_language match > "" (Latin fallback applied by the caller). Also adds an `autoselect` corpus-metadata flag (default true), surfaced during this task: the built-in wuj declares lang=pl, so lang-auto would have re-selected the incomplete Wujek for Polish users and defeated the wuj-drop. wuj.ini now sets autoselect=false, so it is reachable only via an explicit reading_version or --ref; the resolver's language auto-match skips non-autoselectable corpora. A corrected Wujek drop-in (autoselect defaults true) auto-serves Polish with zero config. --- internal/config/config_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'internal/config/config_test.go') diff --git a/internal/config/config_test.go b/internal/config/config_test.go index e3af475..3830cb6 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -301,3 +301,23 @@ func TestPartShown(t *testing.T) { t.Error("ewangelia not mentioned should still be shown") } } + +func TestReadingCorpusResolution(t *testing.T) { + // drb is an embedded corpus with lang=en. + c := Config{ReadingVersion: "drb"} + if got := c.ReadingCorpus(); got != "drb" { + t.Fatalf("explicit reading_version: got %q", got) + } + c = Config{ReadingLang: "en"} + if got := c.ReadingCorpus(); got != "drb" { + t.Fatalf("reading_lang match: got %q", got) + } + c = Config{UILanguage: "en"} + if got := c.ReadingCorpus(); got != "drb" { + t.Fatalf("ui_language fallback: got %q", got) + } + c = Config{UILanguage: "pl"} // no pl corpus embedded + if got := c.ReadingCorpus(); got != "" { + t.Fatalf("no match should be empty: got %q", got) + } +} -- cgit v1.3