Design daw_i18n/v1 text override for host programs #13

Closed
opened 2026-08-14 13:19:46 +02:00 by michael · 2 comments
Owner

Goal

Design how a host program can override a daw_i18n/v1 text
(from a library or module) with its own text for a given resource_id.

Background

Raised while deciding DAW/daw-lua-common#47 (i18n resource file
location). Text override is a special case of the still-open
daw_i18n/v1 discovery/collection question (deliberately kept out of
the daw_i18n/v1 contract itself) and belongs into the same
architecture work as language selection/loading in berhtjan-core.

Scope

  • How a host declares an override for a specific resource_id
  • Where override files live and how they are loaded relative to the
    library/module's own i18n/ resources
  • Interaction with source_hash staleness detection

DAW/daw-lua-common#47

## Goal Design how a host program can override a daw_i18n/v1 text (from a library or module) with its own text for a given resource_id. ## Background Raised while deciding DAW/daw-lua-common#47 (i18n resource file location). Text override is a special case of the still-open daw_i18n/v1 discovery/collection question (deliberately kept out of the daw_i18n/v1 contract itself) and belongs into the same architecture work as language selection/loading in berhtjan-core. ## Scope - How a host declares an override for a specific resource_id - Where override files live and how they are loaded relative to the library/module's own i18n/ resources - Interaction with source_hash staleness detection ## Related DAW/daw-lua-common#47
Author
Owner

Open question: whether the override mechanism belongs into berhtjan-core itself or into the adapter layer (core vs. adapter placement, analogous to the fs.handle -> fs facade pattern in daw-error-standard.md). Not decided yet -- part of the design scope of this issue.

Open question: whether the override mechanism belongs into berhtjan-core itself or into the adapter layer (core vs. adapter placement, analogous to the fs.handle -> fs facade pattern in daw-error-standard.md). Not decided yet -- part of the design scope of this issue.
Author
Owner

Decision summary, delivered in v2.2.0

The placement question of this issue (core or adapter) is answered:
berhtjan-core only resolves texts; it neither finds nor overrides them.

Resolution (berhtjan-core)

  • resolve_resource(resource_id, catalogs, languages) looks a text up in
    one catalog per language and returns { text, requested_language, resolved_language, fallback_occurred }. A language of the chain
    without a catalog is an error (catalog_not_loaded), never skipped.
  • language_chain(ctx) builds the chain: user language, then
    ctx.default_lang unless identical. No implicit English.

Overrides and discovery (host, install time)

  • Libraries and modules ship daw_i18n/v1 sources. The host merges all
    sources by configured priority, per (resource_id, language), into one
    generated Lua data file per language, plus a pointer file naming the
    active generation. A host override is simply a source with a higher
    priority; a partial override (one language) leaves the other languages
    of the resource untouched.
  • The default language must carry every resource; otherwise the build
    aborts and the active generation stays as it is.
  • berhtjan-core provides the logic as pure functions
    (parse_resource_source, generate_catalogs); reading the files and
    activating the result is the host's job. No registry, no scope field.
  • The generated catalogs carry text only. source_hash staleness is a
    check on the source files, not at runtime.

Not resources

  • Texts of user-authored definitions (reports, question catalogs, rule
    messages) stay inline per language in the definition.

Open (not decided here)

  • What the source_hash of an override source refers to.

Delivered by 1772d38, bfff6d0 and f67c14e, released as v2.2.0 together
with daw-lua-common 2.2.0 and daw-lua-net 2.2.0. Loading in the hosts and
the berhtjan-cli migration are tracked in their own repositories.

## Decision summary, delivered in v2.2.0 The placement question of this issue (core or adapter) is answered: berhtjan-core only resolves texts; it neither finds nor overrides them. **Resolution (berhtjan-core)** - `resolve_resource(resource_id, catalogs, languages)` looks a text up in one catalog per language and returns `{ text, requested_language, resolved_language, fallback_occurred }`. A language of the chain without a catalog is an error (`catalog_not_loaded`), never skipped. - `language_chain(ctx)` builds the chain: user language, then `ctx.default_lang` unless identical. No implicit English. **Overrides and discovery (host, install time)** - Libraries and modules ship `daw_i18n/v1` sources. The host merges all sources by configured priority, per (resource_id, language), into one generated Lua data file per language, plus a pointer file naming the active generation. A host override is simply a source with a higher priority; a partial override (one language) leaves the other languages of the resource untouched. - The default language must carry every resource; otherwise the build aborts and the active generation stays as it is. - berhtjan-core provides the logic as pure functions (`parse_resource_source`, `generate_catalogs`); reading the files and activating the result is the host's job. No registry, no scope field. - The generated catalogs carry text only. `source_hash` staleness is a check on the source files, not at runtime. **Not resources** - Texts of user-authored definitions (reports, question catalogs, rule messages) stay inline per language in the definition. **Open (not decided here)** - What the `source_hash` of an override source refers to. Delivered by 1772d38, bfff6d0 and f67c14e, released as v2.2.0 together with daw-lua-common 2.2.0 and daw-lua-net 2.2.0. Loading in the hosts and the berhtjan-cli migration are tracked in their own repositories.
michael 2026-10-17 12:40:38 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-modul-berhtjan-core#13
No description provided.