aboutsummaryrefslogtreecommitdiff
path: root/lib/naming/lang.mli
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-19 23:48:35 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-19 23:48:35 +0200
commitecadd969e1d96918820a1fdac0cf0d520d96ba06 (patch)
treea06ed1160bfd28ae4578d9445242e48ac9ac3ea4 /lib/naming/lang.mli
parent6762ce46af3cb12bc6ae37cda762c5d95add7903 (diff)
parent329d07b49e397cb65ab52e7ca019b47313027136 (diff)
downloadcolitur-ecadd969e1d96918820a1fdac0cf0d520d96ba06.tar.gz
colitur-ecadd969e1d96918820a1fdac0cf0d520d96ba06.zip
feat: naming, localisation and the rebuilt printed output
colitur computed the calendar correctly and could not say what it had computed. A printed ordo read ef-septuagesima-sunday-2 where a reader expects Dominica in Sexagesima, and the wall calendar showed slugs in every cell. lib/naming a language table and a config file, both pure and total, parsing the INI reader Overlay_ini already had lang/ la.ini and en.ini -- 725 names, every one transcribed from the 1962 Missal and citing the line it came from templates the ordo rebuilt as an A5 booklet: one week per page, a table of contents, framed days, a colour swatch; the wall calendar now fills its sheet instead of a quarter of it tools check_citations.py verifies all 400 citations resolve, with 33 self-tests of its own Names resolve through lang -> declared fallback -> the slug, so a partial translation is usable from its first line and the fully degraded case is the old output rather than a blank page. colitur day and colitur readings are BYTE-IDENTICAL to before, verified against main rather than asserted; --lang, --raw and the lang/config subcommands are still to come, and man/colitur-templates.5 still documents the pre-naming view, so writing a custom template needs the source until that lands.
Diffstat (limited to 'lib/naming/lang.mli')
-rw-r--r--lib/naming/lang.mli60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/naming/lang.mli b/lib/naming/lang.mli
new file mode 100644
index 0000000..36931d4
--- /dev/null
+++ b/lib/naming/lang.mli
@@ -0,0 +1,60 @@
+(** A language table: strings to strings, nothing more.
+
+ Knows nothing about calendars, dates or rites, and never touches the
+ filesystem -- callers hand it text. That is what lets every command use it
+ without the kernel learning about presentation.
+
+ Every lookup is TOTAL. A key with no entry returns THE KEY ITSELF, never the
+ empty string: a partial translation must be usable from its first line, and
+ an untranslated day must still print something a reader can act on. This is
+ also why the pre-naming output (bare slugs) is exactly what an empty table
+ produces -- the degraded case is the old behaviour, not a blank page. *)
+
+type t
+
+(** Parse INI text. Never raises. [Error] on a malformed file or a missing
+ [\[meta\] lang].
+
+ Two duplicate policies, both LAST-WINS:
+ - A section name repeated in the file (e.g. two [\[celebration\]]
+ blocks) has ALL of its blocks merged, not only the first -- a
+ 595-entry hand-edited language file WILL grow duplicate section
+ headers as contributors append entries over time, and dropping a
+ later block would silently lose real translations.
+ - Where the same key appears more than once -- within one block or
+ across two of them -- the value from further down the file wins.
+
+ Both read the same order a reader would: later in the file overrides
+ earlier. This is the OPPOSITE direction from
+ {!Colitur_kernel.Overlay_ini.get} ([List.assoc_opt], first match) over
+ the very same [section.fields] shape -- the two modules resolve a
+ duplicate key in opposite directions, so do not assume one's behaviour
+ from the other's. *)
+val of_string : string -> (t, string) result
+
+val code : t -> string
+val fallback_code : t -> string option
+
+(** [with_fallback t base] resolves through [t] first, then [base], then the key. *)
+val with_fallback : t -> t -> t
+
+(** The identity table: every lookup returns its key. This is what [--raw] uses,
+ so raw output is one table passed around rather than a special case threaded
+ through every call site. *)
+val raw : t
+
+val celebration : t -> string -> string
+val season : t -> string -> string
+val rank : t -> string -> string
+val colour : t -> string -> string
+val term : t -> string -> string
+
+(** [weekday t n], 0 = Sunday. Out-of-range [n] returns [string_of_int n]. *)
+val weekday : t -> int -> string
+
+(** [month t n], 1 = January. Out-of-range [n] returns [string_of_int n]. *)
+val month : 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