cadrumo.domain.calculations.registry.modelo_localization module¶
Canonical locale-key identity and scalar resolution for Modelo schemas.
- class ModeloLocalizationFieldKind(*values)[source]¶
Bases:
StrEnumWhich localizable text a modelo locale key addresses.
- LABEL¶
- HELP¶
- TITLE¶
- OFFICIAL_NAME¶
- CasillaLocalizationField¶
The fields a CASILLA carries, which are only its label and its help text.
A narrowing written out twice before this existed. A casilla has no title and no official name – those belong to the modelo and its revision – so keeping this narrow stops a caller asking for a casilla key that can never resolve.
- encode_modelo_locale_segment(value)[source]¶
Encode one dynamic identity as an injective dotted-key segment.
- revision_locale_key(modelo_id, revision_id, field=ModeloLocalizationFieldKind.LABEL)[source]¶
Derive a revision-level presentation key.
- construct_locale_key(modelo_id, revision_id, construct_id, field='title')[source]¶
Derive the edition-scoped presentation key for one construct.
- construct_lineage_locale_key(modelo_id, construct_id, field='title')[source]¶
Derive the modelo-wide key a construct’s title shares across the editions that keep its id.
A construct id is the identity keyed-family inheritance carries from one edition to the next, so it plays the role
continuidad_idplays for a casilla: the tier below the edition key where text every edition agrees on is stored once.
- casilla_occurrence_locale_key(modelo_id, revision_id, casilla_id, field)[source]¶
Derive the exact revision-occurrence key for one casilla field.
- casilla_continuity_locale_key(modelo_id, continuidad_id, field)[source]¶
Derive the stable continuity key for one grounded casilla field.
- casilla_alias_locale_key(modelo_id, revision_id, casilla_id, alias_id, field=ModeloLocalizationFieldKind.LABEL)[source]¶
Derive the presentation key for one casilla alias occurrence.
- enroll_revision_localization(*, modelo_id, revision_id, raw_revision)[source]¶
Attach derived locale identities without copying presentation values.
- resolve_modelo_localization(keys, *, locale, year=None)[source]¶
Resolve exact/variant keys, then continuity, with Spanish fallback.
keysis ordered from most-specific to least-specific. The requested locale is exhausted before the same identity chain is resolved through the mandatory Spanish source. No non-Spanish locale can become another non-Spanish locale’s fallback.Resolution advances on the absence of a VALUE, never on the absence of a key. That distinction is the whole reason the less-specific tiers can fire: the locale scaffold emits an occurrence key for every casilla in every revision, null until translated, and exempts those nulls from the untranslated-string honesty ratchet. So the first key in the chain always exists. A chain that stopped at key EXISTENCE therefore stopped at index zero every time, for every casilla in every revision, and the continuity tier below it was written, scaffolded and never once consulted.
The stop it used to perform was meant to let a revision deliberately blank an inherited label, but the catalogue cannot express that intent: an explicit null and a scaffolded-but-untranslated null are the same bytes, so the stop could only ever suppress translations nobody chose to suppress. Restoring the override needs a way to say “blanked on purpose” in the data, not a stop that fires on every untranslated key.
A requested locale is read only down to the tier at which Spanish resolves. Catalogues store a value at the least specific key that yields the same text, so a Spanish value on a more specific key marks text that differs from the lineage-wide one; a translation stored below that tier translates the other text, and serving it would render a different meaning. Past that barrier the Spanish value itself is returned.
- modelo_localization_source(keys, *, locale, lookup=None)[source]¶
Return the
(key, locale)that serves a chain, orNonewhen nothing does.This is the selection
resolve_modelo_localization()renders, exposed for consumers that report which catalogue coordinate supplied a text.lookupreplaces the shared catalogue read, so catalogue tooling can evaluate a proposed catalogue with exactly the runtime selection rule.A translation renders the Spanish source, so it is read only at the tier where Spanish text resolves or a more specific one. A chain with no Spanish text has nothing to translate and is served by no locale.
- require_modelo_localization(keys, *, locale, year=None)[source]¶
Resolve a label that must exist, refusing an untranslated identity chain.
The same resolution order as
resolve_modelo_localization(); the difference is the contract on absence. A construct title, official modelo name, or revision member label has no honest empty rendering, so an unresolved chain is aMissingTranslationErrorrather thanNonefor the caller to interpret.