Add nameLa mechanism for bilingual header, proof set of 11 feasts + St. Lawrence
Deploy / deploy (push) Successful in 1m32s
Deploy / deploy (push) Successful in 1m32s
Threads an optional nameLa field through SanctoralIdentity/SaintRecord/ TemporalFeastRecord/ActiveOctave so day-label.ts can render real Latin proper names instead of always falling back to English. Authors the proof set: all 11 named temporal feasts plus St. Lawrence (chosen to exercise the octave-headline and octave-commemoration code paths too). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwsZQMjALCvy7u9tFDWmuQ
This commit is contained in:
@@ -19,11 +19,11 @@ export interface CollisionResult {
|
||||
}
|
||||
|
||||
function asWinner(candidate: SanctoralIdentity): DayWinner {
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, rank: candidate.rank };
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, nameLa: candidate.nameLa, rank: candidate.rank };
|
||||
}
|
||||
|
||||
function asCommemoration(candidate: SanctoralIdentity): Commemoration {
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, rank: candidate.rank };
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, nameLa: candidate.nameLa, rank: candidate.rank };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,11 +83,11 @@ export interface OccurrenceResult {
|
||||
}
|
||||
|
||||
function sanctoralCommemoration(candidate: SanctoralIdentity): Commemoration {
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, rank: candidate.rank };
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, nameLa: candidate.nameLa, rank: candidate.rank };
|
||||
}
|
||||
|
||||
function sanctoralWinner(candidate: SanctoralIdentity): DayWinner {
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, rank: candidate.rank };
|
||||
return { kind: 'sanctoral', id: candidate.id, name: candidate.name, nameLa: candidate.nameLa, rank: candidate.rank };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+23
-20
@@ -12,12 +12,14 @@
|
||||
//
|
||||
// Bilingual: every label is built as a `Bi` (`{en, la}`) pair throughout.
|
||||
// Proper names (a saint's name, an octave's name, a named temporal feast's
|
||||
// name) have no authored Latin form anywhere in `data/` today — those use
|
||||
// the English string as their own `la` value too (same "surface real text
|
||||
// rather than block on missing" convention used elsewhere in this app),
|
||||
// rather than leaving Latin mode showing blanks. Only the closed,
|
||||
// name) carry an optional `nameLa` field alongside the required English
|
||||
// `name` — see calendar/types.ts's `SanctoralIdentity.nameLa` doc comment.
|
||||
// Most saints still have no authored Latin name; `biName` falls back to
|
||||
// the English string as the `la` value in that case (same "surface real
|
||||
// text rather than block on missing" convention used elsewhere in this
|
||||
// app), rather than leaving Latin mode showing blanks. The closed,
|
||||
// mechanism-level vocabulary here (weekdays, ranks, season/ordinal
|
||||
// phrasing) has real Latin authored.
|
||||
// phrasing) has always had real Latin authored, independent of this.
|
||||
import type { FeastClass, LiturgicalDay, TemporalCategory, Weekday } from './types';
|
||||
import { easterSunday } from './easter';
|
||||
import { adventStart, firstSundayStrictlyAfter, sundayOnOrBefore } from './temporal';
|
||||
@@ -36,10 +38,11 @@ function bi(en: string, la: string): Bi {
|
||||
return { en, la };
|
||||
}
|
||||
|
||||
/** A proper name with no authored Latin form yet — the English string
|
||||
* stands in for `la` too. See file-header note. */
|
||||
function biFallback(name: string): Bi {
|
||||
return { en: name, la: name };
|
||||
/** A proper name (saint, octave, named temporal feast) with an optional
|
||||
* authored Latin form — falls back to the English string when `nameLa`
|
||||
* hasn't been authored yet, same convention as `biFallback` above. */
|
||||
function biName(name: string, nameLa: string | undefined): Bi {
|
||||
return { en: name, la: nameLa ?? name };
|
||||
}
|
||||
|
||||
function joinBi(items: Bi[], sep = ' — '): Bi {
|
||||
@@ -348,13 +351,13 @@ function temporalLabel(day: LiturgicalDay): Bi {
|
||||
* own winner is the feast itself, handled above before this is ever
|
||||
* called) — kept simple rather than special-cased for that rare edge case
|
||||
* (see applyOctaves's own `isOwnStartDay` comment in calendar/index.ts for
|
||||
* when it can happen). The octave's own `name` has no authored Latin form
|
||||
* (see file header), so both languages currently show the same name text
|
||||
* — only the surrounding phrasing differs. */
|
||||
* when it can happen). Falls back to the English name for `la` too when
|
||||
* the octave's own record has no authored `nameLa` yet (see file header). */
|
||||
function octaveCoreName(octave: ActiveOctave): Bi {
|
||||
const name = biName(octave.name, octave.nameLa);
|
||||
return octave.isClosingDay
|
||||
? bi(`Octave of ${octave.name}`, `In Octava ${octave.name}`)
|
||||
: bi(`${ordinal(octave.dayNumber)} Day within the Octave of ${octave.name}`, `${ordinalLa(octave.dayNumber)} die infra Octavam ${octave.name}`);
|
||||
? bi(`Octave of ${name.en}`, `In Octava ${name.la}`)
|
||||
: bi(`${ordinal(octave.dayNumber)} Day within the Octave of ${name.en}`, `${ordinalLa(octave.dayNumber)} die infra Octavam ${name.la}`);
|
||||
}
|
||||
|
||||
function octaveLabel(octave: ActiveOctave): Bi {
|
||||
@@ -405,8 +408,8 @@ const CROSS_DAY_VESPERS_LABELS: Record<'today' | 'tomorrow', Bi> = {
|
||||
* - `sanctoral`: every commemorated saint, plain name, no rank (multiple
|
||||
* real ones can coexist — e.g. two colliding saints on the same date —
|
||||
* this app's own "generous commemorations" design keeps every one of
|
||||
* them, not just the first). No authored Latin saint names exist yet
|
||||
* (see file header), so `la` falls back to the same English name.
|
||||
* them, not just the first). `la` uses the saint's own `nameLa` when
|
||||
* authored, else falls back to the same English name (see file header).
|
||||
* - `temporal`: the day's own real Sunday/feria identity, if
|
||||
* `decideOccurrence` demoted it to a commemoration (`ordinary-sunday`/
|
||||
* `privileged-feria`/`privileged-feria-minor`) — matched by id against
|
||||
@@ -438,7 +441,7 @@ function collectCommemorations(
|
||||
const octaves: Bi[] = [];
|
||||
for (const c of day.commemorations) {
|
||||
if (c.kind === 'sanctoral') {
|
||||
const name = biFallback(c.name);
|
||||
const name = biName(c.name, c.nameLa);
|
||||
sanctoral.push(
|
||||
c.vespersNote
|
||||
? bi(`${name.en} (${CROSS_DAY_VESPERS_LABELS[c.vespersNote].en})`, `${name.la} (${CROSS_DAY_VESPERS_LABELS[c.vespersNote].la})`)
|
||||
@@ -450,7 +453,7 @@ function collectCommemorations(
|
||||
}
|
||||
} else if (opts.showOctaves && c.id !== opts.excludeOctaveId) {
|
||||
const octave = activeOctaves.find((a) => a.id === c.id);
|
||||
octaves.push(octave ? octaveCommemorationLabel(octave) : biFallback(c.name));
|
||||
octaves.push(octave ? octaveCommemorationLabel(octave) : biName(c.name, c.nameLa));
|
||||
}
|
||||
}
|
||||
return { sanctoral, temporal, octaves };
|
||||
@@ -542,7 +545,7 @@ export function getDayLabel(day: LiturgicalDay): Partial<Record<string, string>>
|
||||
showOctaves: day.temporalCategory === 'ordinary-feria',
|
||||
});
|
||||
const rank = formatRank(day.winner.rank);
|
||||
const winnerName = biFallback(day.winner.name);
|
||||
const winnerName = biName(day.winner.name, day.winner.nameLa);
|
||||
const winner = bi(`${winnerName.en} (${rank.en})`, `${winnerName.la} (${rank.la})`);
|
||||
return joinBi([winner, ...temporal, ...sanctoral, ...octaves]);
|
||||
}
|
||||
@@ -554,7 +557,7 @@ export function getDayLabel(day: LiturgicalDay): Partial<Record<string, string>>
|
||||
// temporal-feasts.ts) and fall through further down.
|
||||
const namedFeast = getTemporalFeastRecord(day.winner.id);
|
||||
if (namedFeast) {
|
||||
const name = biFallback(namedFeast.name);
|
||||
const name = biName(namedFeast.name, namedFeast.nameLa);
|
||||
const primary = namedFeast.rank
|
||||
? bi(`${name.en} (${formatRank(namedFeast.rank).en})`, `${name.la} (${formatRank(namedFeast.rank).la})`)
|
||||
: name;
|
||||
|
||||
@@ -15,6 +15,9 @@ import sanctoralCalendarData from '../data/calendar/sanctoral-calendar.yml';
|
||||
export interface SaintRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
/** Latin form of `name`, when authored — see calendar/types.ts's
|
||||
* `SanctoralIdentity.nameLa` doc comment for the display fallback. */
|
||||
nameLa?: string;
|
||||
rank: FeastClass;
|
||||
common: string;
|
||||
propers: string | null;
|
||||
@@ -138,6 +141,7 @@ for (const mod of Object.values(saintModules)) {
|
||||
export interface SanctoralCandidate {
|
||||
id: string;
|
||||
name: string;
|
||||
nameLa?: string;
|
||||
rank: FeastClass;
|
||||
}
|
||||
|
||||
@@ -157,6 +161,6 @@ export function getSanctoralCandidatesFor(isoDate: string): SanctoralCandidate[]
|
||||
if (!saint) {
|
||||
throw new Error(`sanctoral-calendar.yml references unknown saint id '${id}'`);
|
||||
}
|
||||
return { id: saint.id, name: saint.name, rank: saint.rank };
|
||||
return { id: saint.id, name: saint.name, nameLa: saint.nameLa, rank: saint.rank };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ function applyChristmasOctaveSunday(
|
||||
if (idx !== -1) {
|
||||
commemorations.splice(idx, 1);
|
||||
}
|
||||
return { kind: 'sanctoral', id: displaced.id, name: displaced.name, rank: displaced.rank };
|
||||
return { kind: 'sanctoral', id: displaced.id, name: displaced.name, nameLa: displaced.nameLa, rank: displaced.rank };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ function applyMarianSaturday(
|
||||
if (winner.rank !== 'simplex') {
|
||||
return winner;
|
||||
}
|
||||
commemorations.push({ kind: 'sanctoral', id: winner.id, name: winner.name, rank: winner.rank });
|
||||
commemorations.push({ kind: 'sanctoral', id: winner.id, name: winner.name, nameLa: winner.nameLa, rank: winner.rank });
|
||||
return MARIAN_SATURDAY;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ function applyOctaves(isoDate: string, winner: DayWinner, commemorations: Commem
|
||||
if (cmp < 0 || tiedAgainstClosingDay) {
|
||||
const isOneOfTheseOctaves = octaves.some((o) => o.id === winner.id);
|
||||
if (!isOneOfTheseOctaves) {
|
||||
commemorations.push({ kind: 'sanctoral', id: winner.id, name: winner.name, rank: winner.rank });
|
||||
commemorations.push({ kind: 'sanctoral', id: winner.id, name: winner.name, nameLa: winner.nameLa, rank: winner.rank });
|
||||
resolvedWinner = { kind: 'temporal', id: resolveTemporalId(isoDate) };
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ function applyOctaves(isoDate: string, winner: DayWinner, commemorations: Commem
|
||||
// again alongside itself would be redundant.
|
||||
const isOwnStartDay = octave.dayNumber === 1 && resolvedWinner.kind === 'temporal';
|
||||
if (!isSelf && !isOwnStartDay) {
|
||||
commemorations.push({ kind: 'octave', id: octave.id, name: octave.name });
|
||||
commemorations.push({ kind: 'octave', id: octave.id, name: octave.name, nameLa: octave.nameLa });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export function applyMovableFeasts(isoDate: string, winner: DayWinner, commemora
|
||||
if (resolvedWinner.kind === 'temporal') {
|
||||
commemorations.push({ kind: 'temporal', id: resolvedWinner.id });
|
||||
} else {
|
||||
commemorations.push({ kind: 'sanctoral', id: resolvedWinner.id, name: resolvedWinner.name, rank: resolvedWinner.rank });
|
||||
commemorations.push({ kind: 'sanctoral', id: resolvedWinner.id, name: resolvedWinner.name, nameLa: resolvedWinner.nameLa, rank: resolvedWinner.rank });
|
||||
}
|
||||
resolvedWinner = FEAST_WINNER;
|
||||
continue;
|
||||
@@ -95,7 +95,7 @@ export function applyMovableFeasts(isoDate: string, winner: DayWinner, commemora
|
||||
} else if (compareFeastClass(resolvedWinner.rank, rank) >= 0) {
|
||||
commemorations.push({ kind: 'temporal', id: feast.id });
|
||||
} else {
|
||||
commemorations.push({ kind: 'sanctoral', id: resolvedWinner.id, name: resolvedWinner.name, rank: resolvedWinner.rank });
|
||||
commemorations.push({ kind: 'sanctoral', id: resolvedWinner.id, name: resolvedWinner.name, nameLa: resolvedWinner.nameLa, rank: resolvedWinner.rank });
|
||||
resolvedWinner = FEAST_WINNER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ import { compareFeastClass, minimumOutrightWinningRank } from './commemorations'
|
||||
export interface ActiveOctave {
|
||||
id: string;
|
||||
name: string;
|
||||
/** Latin form of `name`, when authored — see calendar/types.ts's
|
||||
* `SanctoralIdentity.nameLa` doc comment for the display fallback. */
|
||||
nameLa?: string;
|
||||
/** This octave's own effective rank *today* — the ordinary `wins`
|
||||
* threshold on every day except its own closing day, where it's
|
||||
* `closingDayRank` instead (see calendar/types.ts's OctaveConfig).
|
||||
@@ -49,6 +52,7 @@ function considerCandidate(
|
||||
startDate: string,
|
||||
id: string,
|
||||
name: string,
|
||||
nameLa: string | undefined,
|
||||
octave: OctaveConfig | undefined,
|
||||
): void {
|
||||
if (!octave?.enabled || seen.has(id)) {
|
||||
@@ -63,7 +67,7 @@ function considerCandidate(
|
||||
const dayNumber = offset + 1;
|
||||
const isClosingDay = dayNumber === days;
|
||||
const wins = isClosingDay ? (octave.closingDayRank ?? DEFAULT_CLOSING_DAY_RANK) : (octave.wins ?? DEFAULT_WINS);
|
||||
active.push({ id, name, wins, dayNumber, isClosingDay });
|
||||
active.push({ id, name, nameLa, wins, dayNumber, isClosingDay });
|
||||
}
|
||||
|
||||
/** Every octave (sanctoral or temporal) whose window covers `isoDate`,
|
||||
@@ -80,14 +84,14 @@ export function activeOctavesFor(isoDate: string): ActiveOctave[] {
|
||||
for (const candidate of getSanctoralCandidatesFor(candidateDate)) {
|
||||
const record = getSaintRecord(candidate.id);
|
||||
if (record) {
|
||||
considerCandidate(active, seen, isoDate, candidateDate, record.id, record.name, record.octave);
|
||||
considerCandidate(active, seen, isoDate, candidateDate, record.id, record.name, record.nameLa, record.octave);
|
||||
}
|
||||
}
|
||||
|
||||
for (const feastId of temporalFeastIdsStartingOn(candidateDate)) {
|
||||
const record = getTemporalFeastRecord(feastId);
|
||||
if (record) {
|
||||
considerCandidate(active, seen, isoDate, candidateDate, record.id, record.name, record.octave);
|
||||
considerCandidate(active, seen, isoDate, candidateDate, record.id, record.name, record.nameLa, record.octave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ export type MovableAnchor =
|
||||
export interface TemporalFeastRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
/** Latin form of `name`, when authored — see calendar/types.ts's
|
||||
* `SanctoralIdentity.nameLa` doc comment for the display fallback. */
|
||||
nameLa?: string;
|
||||
octave?: OctaveConfig;
|
||||
rank?: FeastClass;
|
||||
anchor?: MovableAnchor;
|
||||
|
||||
@@ -103,6 +103,11 @@ export type TemporalCategory =
|
||||
export interface SanctoralIdentity {
|
||||
id: string;
|
||||
name: string;
|
||||
/** Latin form of `name`, when authored (see `data/calendar/saints/*.yml`'s
|
||||
* own `nameLa` field). Absent for the majority of saints still — display
|
||||
* code falls back to `name` itself when this is missing, same "surface
|
||||
* real text rather than block on missing" convention used elsewhere. */
|
||||
nameLa?: string;
|
||||
rank: FeastClass;
|
||||
}
|
||||
|
||||
@@ -180,7 +185,7 @@ export type Commemoration =
|
||||
// carries no such qualifier.
|
||||
vespersNote?: 'today' | 'tomorrow';
|
||||
} & SanctoralIdentity)
|
||||
| { kind: 'octave'; id: string; name: string };
|
||||
| { kind: 'octave'; id: string; name: string; nameLa?: string };
|
||||
|
||||
export interface LiturgicalDay {
|
||||
/** ISO date, e.g. "2026-08-09" */
|
||||
|
||||
@@ -85,7 +85,7 @@ function commemorationOfDisplacedPredecessor(loser: DayWinner): Commemoration |
|
||||
if (loser.kind !== 'sanctoral' || loser.rank === 'simplex') {
|
||||
return undefined;
|
||||
}
|
||||
return { kind: 'sanctoral', id: loser.id, name: loser.name, rank: loser.rank, vespersNote: 'today' };
|
||||
return { kind: 'sanctoral', id: loser.id, name: loser.name, nameLa: loser.nameLa, rank: loser.rank, vespersNote: 'today' };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ function commemorationOfDisplacedSuccessor(winner: DayWinner, loser: DayWinner):
|
||||
if (forbids) {
|
||||
return undefined;
|
||||
}
|
||||
return { kind: 'sanctoral', id: loser.id, name: loser.name, rank: loser.rank, vespersNote: 'tomorrow' };
|
||||
return { kind: 'sanctoral', id: loser.id, name: loser.name, nameLa: loser.nameLa, rank: loser.rank, vespersNote: 'tomorrow' };
|
||||
}
|
||||
|
||||
function tagVespersFrom(tomorrow: LiturgicalDay): LiturgicalDay {
|
||||
|
||||
Reference in New Issue
Block a user