summaryrefslogtreecommitdiff
path: root/lib/naming
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 11:32:24 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 11:32:24 +0200
commite2e56ac5af290b60ea01037e58e8bc00545c021c (patch)
tree6346f4ee62809323e8fb0f9041b28e35787d9828 /lib/naming
parentc30a35e1da315f2a44e5b53c714bdcf4d8992d2c (diff)
downloadcolitur-e2e56ac5af290b60ea01037e58e8bc00545c021c.tar.gz
colitur-e2e56ac5af290b60ea01037e58e8bc00545c021c.zip
feat(render): Roman week numbers and date spans, as data
The ordo booklet's week header repeated the month name on every week even though the heading above already established it -- pure noise. Replace it with a Roman week number plus the span of dates the week covers, e.g. "Hebdomada I (Ian 1-2)", following the project's own rule that a presentation choice is data, not code. lang/{la,en}.ini gain a [month_abbr] section (three-letter month abbreviations); Lang.month_abbr follows Lang.month's exact shape, including the out-of-range and miss-returns-the-key contracts. The coverage test now fails loudly if an abbreviation goes missing, the same as [month] already does. Every week object in the view gains num_roman (Roman numeral, num stays as the arabic original -- Roman is a presentation choice, not an engine change), first_dom/last_dom (the day-of-month of the week's first and last IN-MONTH days, padding excluded), month_abbr (resolved through Lang.month_abbr), and single_day (true when the week holds exactly one in-month day). single_day is a flag, not a preformatted span string: the engine is logic-less and cannot itself decide between "Ian 1" and "Ian 1-2", so a template makes that call from the flag instead -- the same "shape the data, not the template" discipline in_month and last already follow. Weeks are built per month with padding only at the two ends, so a week's in-month days never cross a month boundary -- verified, not assumed: every week always has at least one real day since no month is shorter than a single week. Covered by three new View tests, including a real single-day-week witness (January 2027's own trailing week is a lone Sunday, the 31st).
Diffstat (limited to 'lib/naming')
-rw-r--r--lib/naming/lang.ml14
-rw-r--r--lib/naming/lang.mli7
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/naming/lang.ml b/lib/naming/lang.ml
index 92c8a9a..2301513 100644
--- a/lib/naming/lang.ml
+++ b/lib/naming/lang.ml
@@ -10,6 +10,7 @@ type t = {
celebration : table;
weekday : table;
month : table;
+ month_abbr : table;
season : table;
rank : table;
colour : table;
@@ -54,13 +55,17 @@ let month t n =
if n < 1 || n > 12 then string_of_int n
else match lookup t (fun x -> x.month) (string_of_int n) with Some v -> v | None -> string_of_int n
+let month_abbr t n =
+ if n < 1 || n > 12 then string_of_int n
+ else match lookup t (fun x -> x.month_abbr) (string_of_int n) with Some v -> v | None -> string_of_int n
+
let code t = t.code
let fallback_code t = t.fallback_code
let raw =
{ code = "raw"; fallback_code = None; celebration = empty_table; weekday = empty_table;
- month = empty_table; season = empty_table; rank = empty_table; colour = empty_table;
- term = empty_table; rite = empty_table; chain = None }
+ month = empty_table; month_abbr = empty_table; season = empty_table; rank = empty_table;
+ colour = empty_table; term = empty_table; rite = empty_table; chain = None }
let with_fallback t base = { t with chain = Some base }
@@ -96,6 +101,7 @@ let of_string text =
celebration = find "celebration";
weekday = find "weekday";
month = find "month";
+ month_abbr = find "month_abbr";
season = find "season";
rank = find "rank";
colour = find "colour";
@@ -107,6 +113,6 @@ 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 "season" t.season; qualify "rank" t.rank;
- qualify "colour" t.colour; qualify "term" t.term; qualify "rite" t.rite ]
+ 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 ]
|> List.sort compare
diff --git a/lib/naming/lang.mli b/lib/naming/lang.mli
index 4d7f82f..34a6d5d 100644
--- a/lib/naming/lang.mli
+++ b/lib/naming/lang.mli
@@ -61,6 +61,13 @@ val weekday : t -> int -> string
(** [month t n], 1 = January. Out-of-range [n] returns [string_of_int n]. *)
val month : t -> int -> string
+(** [month_abbr t n], 1 = January, e.g. ["Ian"]/["Jan"]. Same shape as
+ {!month}: out-of-range [n] returns [string_of_int n], and a miss falls
+ back through the chain to [string_of_int n] as well, never to [month]'s
+ own full name -- an abbreviation is its own vocabulary, not a truncation
+ of another lookup. *)
+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"]. *)
val keys : t -> (string * string) list