Skip to content

fix(i18n): only inline the source locale when it is requested - #200

Merged
Aukevanoost merged 1 commit into
mainfrom
fix/i18n-stale-source-locale
Oct 28, 2026
Merged

Aukevanoost merged 1 commit into
mainfrom
fix/i18n-stale-source-locale

Conversation

@Aukevanoost

@Aukevanoost Aukevanoost commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

With a target locale such as localize: ['de'], a watch rebuild (ng serve or ng build --watch) ships source-language text in the target locale.

translateFederationArtifacts always passed -l <source>, so localize-translate also wrote an inlined copy of the source locale, which was copied back over the source folder. Core doesn't rewrite shared bundles on a rebuild, so the next run staged those already-inlined files and translated them again. In practice that hits core's $localize.locale: LOCALE_ID falls back to the source locale after the first edit, and any $localize message in a shared package shows the source text.

Change

Only pass -l when the source locale is requested (localize: true, or a list that contains it). Without -l the CLI writes no source copy, so the source folder keeps its raw $localize calls and every run starts from untranslated input.

Not covered

When the source locale is requested together with a target locale (localize: true or ['en', 'de'] under ng build --watch), the source folder still has to be inlined in place, so de still gets the source text after a rebuild. Fixing that needs the adapter to skip files that are unchanged since its last run; that's left for a follow-up. ng serve turns true and multi-locale lists off, so it isn't affected.

Passing -l always made localize-translate overwrite the source folder with an
inlined copy. Shared bundles are not rewritten on a watch rebuild, so the next
run staged that copy and the target locales got the source-language text.
@Aukevanoost
Aukevanoost merged commit 8a9ce22 into main Oct 28, 2026
1 check passed
@Aukevanoost
Aukevanoost deleted the fix/i18n-stale-source-locale branch October 28, 2026 13:17
Aukevanoost added a commit that referenced this pull request Oct 28, 2026
Backports 22.2.3..22.2.4 onto the Angular 21 layout.

Incoming:
- #167/#169: the dev server keeps federation externals out of the
  stylesheet build; Angular's ssr/prerender corrections reach serveWithVite.
- #166/#168: context tsconfigs pass `types` resolved instead of widening
  typeRoots.
- #173/#176/#186/#200: i18n translates every federation output, honours
  outputPath.browser, stays under the Windows command line limit, inlines
  the source locale only when requested and refreshes integrity hashes.
- #187/#190: optional-peer entry points are skipped only when the peer is
  missing; @angular/localize is an optional peer.
- #189/#195/#196: federation build results carry their entry; a path
  written twice is reported once.
- #194: @softarc/native-federation ~4.9.0, orchestrator ^4.9.0.

Angular 21 specific adaptations:
- Checked the #167/#169 assumptions against @angular/build 21.2.24:
  serveWithVite reads externalDependencies and ssr back from the options it
  passed, and the stylesheet bundler uses externalDependencies, as on 22.
- No // upstream: tags change (still angular-cli v21.2.19, 1a728258d6).
- Skipped #188/#198 (remote builder): this branch has no remote builder.
- Kept the internal builder without instrumentForCoverage; dropped it from
  the incoming spec.
- Moved output-entries and the i18n integration spec into src/utils.
- Skipped the `types: ["*"]` spec below TypeScript 6 (branch is on 5.9).
- @angular/localize optional peer/devDependency at >=21.2.0/^21.2.0.
- Kept the -v4 name, 21.2.16 version, ng21 pins and this branch's global
  pnpm overrides; main's vite 8 override doesn't apply to 21.2's vite 7.
- pnpm-lock.yaml regenerated rather than merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant