Repository navigation
chore(i18n): upgrade ngx-translate to v18 and replace TranslateModule - #654
Conversation
E2E — mocked backend🎭 E2E Tests✅ All green — 409 passed · 0 failed · 1 skipped, across 38 spec files in 5m 57s. By spec file
All 410 tests — click to expand
Slowest 10 — what the shard counts should be tuned against
📼 Download the HTML report, videos and traces — see the Generated by run 36977868160 from |
E2E — real Fineract🎭 E2E Tests✅ All green — 96 passed · 0 failed · 0 skipped, across 31 spec files in 7m 27s. By spec file
All 96 tests — click to expand
Slowest 10 — what the shard counts should be tuned against
📼 Download the HTML report, videos and traces — see the Generated by run 36977868160 from |
What and why
Moves
@ngx-translate/coreand@ngx-translate/http-loaderfrom 17 to 18 and migrates the code that release breaks. ngx-translate 18 removesTranslateModule, which 291 files import, so the bump cannot land on its own: Dependabot's #564 bumps the same two packages and fails Production Build, Unit Tests, Offline Production Build, Container Image and every E2E run. This supersedes it.Closes #167
What 18 breaks here
TranslateModuleis gone. The pipe is standalone and exported asTranslatePipe. The 291 files that imported the module are: 220 components, which now importTranslatePipein its place; 14 components that imported it without using thetranslatepipe at all, so the import is dropped; 55 specs (below); andapp.config.tsand the shared test helper, done by hand.TranslateModule.forRoot()in specs. 57 test beds in 55 spec files now take...provideTranslateTesting(). That is the existing shared helper, which now callsprovideTranslateService().app.config.tsusesprovideTranslateService({ missingTranslationHandler, loader }). The loader is passed asprovideTranslateLoader(DeploymentTranslateLoader): a bare class works but makes the library log a console warning at startup. I did not addlangorfallbackLang. Either one makesTranslateService's constructor load a catalogue immediately (for a root service they are the only two things its constructor acts on), which is the re-entrancy problem the comment there already describes. That comment stays, reworded for 18.TranslateStore.getCurrentLang()is gone, whichReportingMissingTranslationHandlerused to know whether a catalogue had loaded. It now asks the service the miss came from (params.translateService), which is also the right one if a subtree ever has its own. The handler no longer injects the store, and its spec builds that service directly instead of poking the store.http-loader18 peers@ngx-translate/core >=18.0.0, so the pair has to move together. The lockfile change is just those two packages.Behaviour changes in 18 that I checked and that need no code
use()no longer changescurrentLang(). TheI18Nadapter mirrorsonLangChange, so it follows whatever the service does.provideChildTranslateService.ITranslateServicegainsisLoading. Nothing here implements or mocks that interface.<span translate>KEY</span>) is deprecated. A search of every template for thetranslatedirective found none.DeploymentTranslateLoaderalready handles a missing overlay file itself, so that stays quiet; a failing shipped catalogue is now visible.How the files were changed
Apart from the two hand-edited files, by a script that edits the TypeScript syntax tree rather than text, so each change is one of three shapes:
TranslateModule→TranslatePipein a component'simports, the import dropped when the template never uses the pipe, orTranslateModule.forRoot()in a test bed →provideTranslateTesting(). 10 of the files already import the app's ownTranslatePipe(theappTranslatepipe), so there the library's is imported asTranslatePipe as NgxTranslatePipe; the template name is stilltranslate. The compiler is the check on the first two shapes: a template using| translatewithout the pipe imported does not build.Commits
Split for reading, so the hand-written part can be reviewed on its own:
chore(deps): move ngx-translate to 18:package.jsonand the lockfile, just the two packages.refactor(i18n): update ngx-translate integration: the hand-written changes.app.config.ts, the missing-translation handler, the shared test helper, docs and comments, and the pruned lint baseline (npm run lint:prune: 322 lines removed and three counts lowered from 2 to 1, nothing added).refactor(i18n): replace TranslateModule imports: 233 files, mechanical.test(i18n): migrate translation test providers: 56 files, mechanical.app.component.tsand its spec: the same two shapes.Because 18 removes
TranslateModule, a commit in the middle does not build and pass its tests on its own; the series is the unit.Not in this PR
| translateto the adapter's| appTranslate. That is the larger migration the adapter boundary points at, and it would touch the same 220 templates again.@ngx-translate/http-loaderis not imported anywhere sinceDeploymentTranslateLoaderreplaced it (d5c8a59). It is bumped here because the issue, the Dependabot group and the peer range treat the two as a pair; removing it is a one-line follow-up if you would rather.Verification
Exercised against mocks. Not run against a real Fineract, and the offline container build was not run either: both need Docker, which was not running.
npm run buildwas.npm run lint,format:check,i18n:check,check:icons,check:a11y-names,check:ui-primitives,check:responsive,api:surface,typecheck:e2e,build: pass. The build reports no unused-import warnings and only the existingheader.componentstyle budget warning.npm run test:unit: 266 files, 1753 tests pass, the same counts as before the change.npm ci --dry-runresolves from the lockfile;npm audit --audit-level=high --omit=dev: 0 vulnerabilities;license-checkerwith the allowed list andscripts/check-license.sh: pass.loan-product-down-payment.spec.ts"down payment is offered only for a progressive product": the sharedselectOptionhelper timed out waiting for an Ionic popover to close, under 4 workers. Run alone three times over (39 tests), it passes every time, and nothing in it touches translation.mobileproject: 25 passed, 5 skipped (viewport guards).login.submit.Screenshots
Not applicable. No visible change; the rendered text is the same.
AI assistance (optional)
Checklist
src/app/api/.src/app/core/adapters/instead of direct browser globals or imperative third-party APIs. (No new vendor use: the same files keep the import they already had, and 55 specs lose theirs.)