OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Runtime and adapters
Translation runtime and i18next adapter
Use ContractSpec as the canonical translation contract layer, then resolve and format messages through a framework-independent runtime. i18next is supported as an optional downstream adapter, not as the source of truth.
Install the runtime
bun add @lssm-tech/lib.contracts-spec @lssm-tech/lib.translation-runtimeAdd
i18nextonly when an app imports the adapter subpath. Core server, React, React Native, CLI, and test code can use the runtime without loading i18next.
Spec layer
TranslationSpec owns keys, locales, domains, versions, owners, fallback declarations, direction, and validation metadata.
Runtime layer
The createI18nFactory stack resolves locales, applies fallback chains, formats ICU messages, reports diagnostics, and builds locale-scoped SSR snapshot/hydration payloads. The legacy createTranslationRuntime engine has been removed; createI18nFactory (and createManagedCompanyOsI18n for the managed surface) is the canonical runtime.
Sharding & SSR layer
Route shard manifests scope a per-route hydration payload to the catalogs a page actually renders; slim + value-pool wire encoding shrinks the per-request inline HTML (~60%) while catalogs stay bundled/cached. The loader lazy-loads only newly-required shards on navigation (computeShardDelta / loadShardDelta), and ./precompile emits a build-time ICU AST fast-path.
Adapter layer
The i18next adapter projects ContractSpec specs or snapshots to resources and manifests for caller-owned i18next instances.
Use the ContractSpec runtime
The runtime consumes canonical
TranslationSpec[]catalogs, supports BCP 47 tags such as en-US, ar-EG, and zh-Hans, and delegates ICU parsing/formatting to a mature formatter engine instead of a custom parser.
import { createI18nFactory } from '@lssm-tech/lib.contracts-spec/translations';
import { checkoutEn, checkoutFr } from './translations/checkout.messages';
// One factory per stable spec key; resolution stays on the canonical
// createI18nFactory stack (the deprecated createTranslationRuntime engine
// was removed — see the migration note below).
const checkoutI18n = createI18nFactory({
specKey: 'checkout.messages',
catalogs: [checkoutEn, checkoutFr],
});
const instance = checkoutI18n.create('fr-FR');
const label = instance.t('checkout.pay', { amount: 4200, currency: 'EUR' });Project to i18next when needed
Import from
@lssm-tech/lib.translation-runtime/i18nextto export resources by locale, namespace, and message key. The namespace defaults to the stable bundle key, dotted message keys stay flat with keySeparator false, and metadata remains in a sidecar manifest.
import { createInstance } from 'i18next';
import {
createI18nextInitOptions,
exportContractSpecToI18next,
} from '@lssm-tech/lib.translation-runtime/i18next';
const exported = exportContractSpecToI18next([checkoutMessages], {
locale: 'en-US',
assumeIcuFormatter: true,
});
const { options, diagnostics } = createI18nextInitOptions(exported, {
lng: 'en-US',
});
const i18next = createInstance();
await i18next.init(options);
reportAdapterDiagnostics(diagnostics);SSR, streaming, and hydration
Negotiate locale on the server, preload catalogs needed for streamed content, and hydrate the client from the same serialized state. Never let client-only language detection choose a different locale after the server has rendered.
// Server: build a locale-scoped hydration payload from the factory and ship it.
import {
createI18nFactory,
createI18nFactoryHydrationPayload,
serializeI18nFactoryHydrationPayload,
} from '@lssm-tech/lib.contracts-spec/translations';
const factory = createI18nFactory({ specKey: 'checkout.messages', catalogs });
const payload = createI18nFactoryHydrationPayload(
factory.snapshot(negotiatedLocale),
);
const serialized = serializeI18nFactoryHydrationPayload(payload); // inline into HTML
// Client: rehydrate the SAME locale-scoped catalogs before first paint — no
// locale renegotiation, no key/fallback flash.
import { createI18nFactoryFromHydrationPayload } from '@lssm-tech/lib.contracts-spec/translations';
const hydrated = createI18nFactoryFromHydrationPayload(serialized).create(
negotiatedLocale,
);Production checklist
Use createI18nFactory (or createManagedCompanyOsI18n) as the runtime — the deprecated createTranslationRuntime engine and its ./runtime, ./registry, and ./runtime-helpers subpaths were removed.
For SSR, ship a locale-scoped factory hydration payload and rehydrate it before first paint; do not renegotiate locale on the client.
Keep TranslationSpec as the source of truth; do not flatten metadata into i18next JSON as the canonical model.
Keep stable bundle identity in TranslationSpec.meta.key and keep BCP 47 language tags in TranslationSpec.locale.
Use ICU messages for plural, select, selectordinal, number, date, currency, list, and relative-time formatting.
Create one runtime per SSR request when tenant, project, or user overrides are involved.
Serialize the same runtime snapshot or exported adapter resources used by the server for hydration.
Configure an ICU-capable i18next formatter plugin when rendering ContractSpec ICU messages through i18next.
Treat adapter diagnostics as release blockers in production pipelines instead of silently rendering raw keys.
Agent implementation prompt
Use this prompt when asking an agent to wire translations into a web, server, or React Native surface without losing ContractSpec ownership.
You are integrating ContractSpec translations into a production app.
Use @lssm-tech/lib.contracts-spec/translations as the canonical contract layer and the createI18nFactory stack as the runtime (the deprecated createTranslationRuntime engine has been removed). @lssm-tech/lib.translation-runtime provides the loader (shard scoping), ICU formatter, ./precompile fast-path, diagnostics, and the optional i18next adapter.
Keep locale variants separate from stable bundle keys, support BCP 47 tags, and preserve ICU plural/select/selectordinal messages. For SSR, build a locale-scoped factory hydration payload per request and rehydrate it before first paint.
If the app already uses i18next, use @lssm-tech/lib.translation-runtime/i18next only as a downstream adapter. Do not make i18next the canonical translation model. Include diagnostics, fallback behavior, and SSR hydration handling in the implementation and tests.Personalization
Track behavior events, resolve DataView preferences, and convert insights into overlays or workflow adaptations.
Design system
Adopt high-level product UI primitives, actionable object references, responsive AdaptivePanel overlays, forms, data tables, and theme helpers.
Why ContractSpec
Keep educational and comparison content reachable without letting it define the primary OSS learning path.