summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/naming/lang.ml24
-rw-r--r--lib/naming/lang.mli27
2 files changed, 48 insertions, 3 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
diff --git a/lib/naming/lang.mli b/lib/naming/lang.mli
index 34a6d5d..3c62d26 100644
--- a/lib/naming/lang.mli
+++ b/lib/naming/lang.mli
@@ -55,6 +55,13 @@ val term : t -> string -> string
degradation an unnamed slug already gets, not a special case. *)
val rite : t -> string -> string
+(** A Bible book's name, from the [\[bible\]] section. The key is
+ [<book_id>.full] or [<book_id>.abbr] (e.g. ["luke.abbr"]). A miss returns
+ the key itself, the same TOTAL-lookup contract as every other function
+ here -- callers turn that into a real fallback via
+ {!Colitur_citation.Book.default_spelling}, not this module. *)
+val bible : t -> string -> string
+
(** [weekday t n], 0 = Sunday. Out-of-range [n] returns [string_of_int n]. *)
val weekday : t -> int -> string
@@ -69,5 +76,23 @@ val month : t -> int -> string
val month_abbr : t -> int -> string
(** Every (section-qualified key, value) pair, sorted. Used by [lang --dump] and
- [lang --check]. Keys are qualified as e.g. ["celebration.ef-epiphany"]. *)
+ [lang --check]. Keys are qualified as e.g. ["celebration.ef-epiphany"].
+
+ Includes [\[bible\]] (["bible.luke.abbr"]): book names are translatable
+ text, so a file missing them is genuinely incomplete and [lang --check]
+ should say so. Deliberately EXCLUDES [\[sigla\]]: those are five citation-
+ style settings with working defaults ({!Colitur_citation.Render.default_style}),
+ not names a translator owes -- listing them here would make [--check]
+ demand five settings from every language file. *)
val keys : t -> (string * string) list
+
+(** The [\[sigla\]] section's raw fields, for
+ {!Colitur_citation.Render.style_of_fields} to read. Values come back
+ TRIMMED (whitespace at both ends) but still QUOTED if the file quoted
+ them -- unquoting is [Render]'s job, not this module's, the same reason
+ {!Colitur_kernel.Overlay_ini} (which this parses through) never unquotes
+ either. An empty (or absent) [\[sigla\]] section returns [[]]; unlike
+ every lookup above, there is no per-key TOTAL contract to keep here --
+ this is a settings bag, not a translation table, and [Render] already
+ supplies its own defaults for whatever is missing. *)
+val sigla_fields : t -> (string * string) list