aboutsummaryrefslogtreecommitdiff
path: root/lib/naming/lang.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 15:49:00 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 15:49:00 +0200
commitc02e77b73aad34fb5a672a5234a66d64f23b45ce (patch)
treebff3ae0751e8005bc4f5448cc2992c3bcad2d86b /lib/naming/lang.ml
parent987175105ead0ea78b960c0e638a81c6fd2384cf (diff)
downloadcolitur-c02e77b73aad34fb5a672a5234a66d64f23b45ce.tar.gz
colitur-c02e77b73aad34fb5a672a5234a66d64f23b45ce.zip
feat(lang): read [bible] and [sigla] sections
Lang reads a hardcoded list of section names and ignores anything else silently, so without this a [bible] section would appear to work and do nothing -- confirmed directly with a scratch executable: before this change, of_string on text containing a [bible] section parsed without error and Lang.keys came back empty, no trace of the section anywhere. Lang.bible keeps the total-lookup contract every other lookup in this module has: a miss returns the key itself, never the empty string. Lang.sigla_fields returns the [sigla] section's raw fields, values trimmed but still quoted, for Render.style_of_fields to unquote. [bible] joins the keys reference set so lang --check reports missing book names; [sigla] deliberately does not, being settings with working defaults rather than translatable names -- adding it would make --check demand five settings from every language file.
Diffstat (limited to 'lib/naming/lang.ml')
-rw-r--r--lib/naming/lang.ml24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/naming/lang.ml b/lib/naming/lang.ml
index 2301513..f0fd989 100644
--- a/lib/naming/lang.ml
+++ b/lib/naming/lang.ml
@@ -16,6 +16,8 @@ type t = {
colour : table;
term : table;
rite : table;
+ bible : table;
+ sigla : table;
chain : t option; (** consulted when this table misses *)
}
@@ -35,6 +37,14 @@ let rank t k = get t (fun x -> x.rank) k
let colour t k = get t (fun x -> x.colour) k
let term t k = get t (fun x -> x.term) k
let rite t k = get t (fun x -> x.rite) k
+let bible t k = get t (fun x -> x.bible) k
+
+(* Not routed through [get]/[chain]: [sigla] is a set of RENDER SETTINGS
+ (Render.style_of_fields), not a per-key translation lookup, and it has no
+ miss-returns-the-key contract to keep -- a caller with no [sigla] table at
+ all just gets []. Order does not matter to callers (Render.style_of_fields
+ reads them by name), so [SM.bindings] (alphabetical) is fine here. *)
+let sigla_fields t = SM.bindings t.sigla
let weekday_key = [| "sunday"; "monday"; "tuesday"; "wednesday"; "thursday"; "friday"; "saturday" |]
@@ -65,7 +75,8 @@ let fallback_code t = t.fallback_code
let raw =
{ code = "raw"; fallback_code = None; celebration = empty_table; weekday = empty_table;
month = empty_table; month_abbr = empty_table; season = empty_table; rank = empty_table;
- colour = empty_table; term = empty_table; rite = empty_table; chain = None }
+ colour = empty_table; term = empty_table; rite = empty_table; bible = empty_table;
+ sigla = empty_table; chain = None }
let with_fallback t base = { t with chain = Some base }
@@ -107,12 +118,21 @@ let of_string text =
colour = find "colour";
term = find "term";
rite = find "rite";
+ bible = find "bible";
+ sigla = find "sigla";
chain = None })
+(* [bible] joins this reference set: it is translatable book names, so a file
+ lacking them is genuinely incomplete and [lang --check] should say so.
+ [sigla] deliberately does NOT: it is five citation-style settings with
+ working defaults (Render.default_style), not names a translator owes --
+ adding it here would make [--check] demand five settings from every
+ language file that has never needed them. *)
let keys t =
let qualify prefix m = SM.bindings m |> List.map (fun (k, v) -> (prefix ^ "." ^ k, v)) in
List.concat
[ qualify "celebration" t.celebration; qualify "weekday" t.weekday;
qualify "month" t.month; qualify "month_abbr" t.month_abbr; qualify "season" t.season;
- qualify "rank" t.rank; qualify "colour" t.colour; qualify "term" t.term; qualify "rite" t.rite ]
+ qualify "rank" t.rank; qualify "colour" t.colour; qualify "term" t.term; qualify "rite" t.rite;
+ qualify "bible" t.bible ]
|> List.sort compare