lingex-i18n
LingEx i18n
Source details
- Source revision
abc577bb0082aed0ca5aa8190a4f3e945deb1db4- Source SHA-256
818fc61afadb70f75508e678923ab184ffd233450253fbb1ab9f503aee946a96
LingEx i18n
lingex-i18n is the canonical shared localisation service and contract package for LingEx user-interface text.
It owns the reusable runtime rules by which LingEx modules declare localisation namespaces, resolve stable translation keys, select the active UI locale, load database-backed translations and expose the loaded catalogue to browser code.
Canonical data model
User-facing interface strings are addressed by stable keys:
namespace.string_key
The canonical runtime source of truth for visible interface text is the database, including English. Application code and templates use keys rather than embedding a second authoritative copy of the visible string.
The runtime fallback order is:
active UI-language translation
-> English database translation
-> raw localisation key
A missing key may be recorded for operational review, but missing-translation logging must never break page rendering.
The i18n-owned database family comprises the translation catalogue tables, including namespace, key, translation, missing-translation and catalogue revision state. Canonical language identity/availability is shared language data consumed by i18n; lingex-i18n does not become the owner of the complete LingEx language taxonomy.
Repository-local JSON/catalogue files may be used as controlled authoring, import/export, fixture, validation or release artefacts. They are not a second runtime authority for database-backed visible text.
Namespace ownership
Each owning module declares and maintains its own localisation namespace or namespaces. Shared strings belong only in deliberately shared namespaces.
A module must not register translations by editing another repository's private registry. Module contributions and approved seed/import tooling feed the shared i18n contract while the originating module retains ownership of its module-specific keys and copy.
The i18n service owns the shared namespace/key/translation contract, validation, fallback behaviour and runtime access API. It does not take ownership of a product module's business meaning merely because that module's strings are stored through the shared service.
Runtime contract
The canonical PHP runtime exposes the shared LingEx localisation API, including:
lingex_i18n_bootstrap([...]);
lx_t('namespace.string_key');
lx_t_raw('namespace.string_key');
lx_i18n_script();
LingExI18n::locale();
LingExI18n::loadNamespaces([...]);
lx_t() returns HTML-escaped text. lx_t_raw() returns raw translated text for callers that will perform the appropriate context-specific escaping.
Browser clients receive only the namespaces loaded for the rendered surface. The browser helper resolves those already-authorised catalogue values; it is not a second translation store.
UI-language resolution
ui_language, source_language and target_language are distinct concepts.
The UI locale is resolved through the shared LingEx language-context rules, using explicit request choice, persisted user/session preference where available, the LingEx UI-language cookie, browser language preference and English fallback in that precedence order.
Learning source/target language state remains owned by the appropriate learning or language subsystem and must not be conflated with interface localisation.
Database-access boundary
i18n continues to own its schema semantics and migration declarations. Executable migration custody is held by Persistence, whose catalogue preserves the original i18n repository, logical migration root, path, key, ordering and applied-state mapping. The i18n module contribution retains that logical root; it does not designate the physical execution location.
The approved architecture requires lingex-i18n to consume the canonical Core-provided database-access service/contract rather than owning an ad-hoc database bootstrap.
The current implementation has not fully reached that boundary: its runtime helper still reaches the database and enabled-language data through explicit compatibility bridges. Those bridges describe current implementation, not the permanent dependency direction.
Does not own
lingex-i18n does not own:
- authentication/session policy;
- general user identity;
- the complete natural-language taxonomy or linguistic research data;
- learning source/target-language business rules;
- route selection or controllers;
- page/document rendering;
- theme tokens or CSS;
- product-specific business logic;
- publication or access-control decisions.
Repository verification
bash scripts/install-version-hook.sh
bash scripts/verify-repo-shape.sh
bash scripts/check-architecture.sh
php tests/test-release-repository-isolation.php