Repository navigation
refactor(i18n)!: rewrite the locales service - #47
Merged
Merged
Conversation
added 3 commits
October 4, 2026 17:00
Split the old LocalesService into a pure Translator (per-key fallback chain, Intl plurals, no catalog cloning), a language state with detection, persistence and SSR-safe guards, and sources that load one language at a time. Errors are events and rejections, never return values. Binders restore the source markup when a key is missing or the source language is active. Consumers follow in the next commit.
shopify-tda requests one file for all languages and adds ?shop= in a buildUrl hook (the Shopify coupling left the generic rest service). shopify-nest reads the service from I18nService instead of the removed static instances. The doc site test used a catalog with a bogus langcode.
README, reference pages and a MIGRATION.md section for the breaking changes of the rewrite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rewrites
@ribajs/i18nand moves its consumers along. Breaking, documented inMIGRATION.md(section "2.0.0 release candidates → next").de-AT→de→fallbackLangcodes),Intl.PluralRulesplurals,{{ var }}interpolation, no catalog cloning, empty strings are valid translations.sourceLangcode,detect(query/storage/html/navigator),persist,<html lang>sync, alldocument/navigator/localStorageaccess guarded (SSR-safe).init()/whenReady(), typed eventsready/changed/missing/errorper service instance, errors as events and rejections instead of return values,dispose(), stale-switch protection.LocalesRestServiceloads one language at a time (url or(langcode) => url), withbuildUrl/parse/resolveLangcodeshooks; the Shopify?shop=coupling moved to@ribajs/shopify-tda.unbind;tis synchronous and accepts variables and a langcode.doc/reference/i18n/*,MIGRATION.md.Verification
yarn test: 941 passed (874 before)tsc --noEmit: i18n, shopify-tda, shopify-nest, demos/i18n-static, infra/docbuild:demos45/45,smoke:demos45 ok,yarn workspace @ribajs/doc buildokdemos/i18n-staticswitches en → de → en → de correctly without console errorse2e/has no references to i18n;yarn test:e2edoes not run locally (Playwright PnP loader), so CI is its first runNot run: ESLint (the repo config fails to load on
mainas well),yarn build:libs.