shivaansh0610-LUFFY opened a new pull request, #654:
URL: https://github.com/apache/fineract-backoffice-ui/pull/654

   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
     http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   
   <!-- Commits must be signed to merge — see CONTRIBUTING.md#commit-signing if 
you haven't set this up. -->
   
   ## What and why
   
   <!-- One or two sentences explaining what changed and why. -->
   
   Moves `@ngx-translate/core` and `@ngx-translate/http-loader` from 17 to 18 
and migrates the code that release breaks. ngx-translate 18 removes 
`TranslateModule`, 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
   
   - **`TranslateModule` is gone.** The pipe is standalone and exported as 
`TranslatePipe`. The 291 files that imported the module are: 220 components, 
which now import `TranslatePipe` in its place; 14 components that imported it 
without using the `translate` pipe at all, so the import is dropped; 55 specs 
(below); and `app.config.ts` and 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 calls `provideTranslateService()`.
   - **`app.config.ts`** uses `provideTranslateService({ 
missingTranslationHandler, loader })`. The loader is passed as 
`provideTranslateLoader(DeploymentTranslateLoader)`: a bare class works but 
makes the library log a console warning at startup. I did not add `lang` or 
`fallbackLang`. Either one makes `TranslateService`'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**, which 
`ReportingMissingTranslationHandler` used 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-loader` 18 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
   
   - A failed `use()` no longer changes `currentLang()`. The `I18N` adapter 
mirrors `onLangChange`, so it follows whatever the service does.
   - Isolated subtrees no longer inherit from their ancestors. Nothing here 
uses `provideChildTranslateService`.
   - `ITranslateService` gains `isLoading`. Nothing here implements or mocks 
that interface.
   - Element text as a key (`<span translate>KEY</span>`) is deprecated. A 
search of every template for the `translate` directive found none.
   - Loader errors are now logged instead of swallowed. 
`DeploymentTranslateLoader` already 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` → `TranslatePipe` in a component's `imports`, the import 
dropped when the template never uses the pipe, or `TranslateModule.forRoot()` 
in a test bed → `provideTranslateTesting()`. 10 of the files already import the 
app's own `TranslatePipe` (the `appTranslate` pipe), so there the library's is 
imported as `TranslatePipe as NgxTranslatePipe`; the template name is still 
`translate`. The compiler is the check on the first two shapes: a template 
using `| translate` without the pipe imported does not build.
   
   ### Commits
   
   Split for reading, so the hand-written part can be reviewed on its own:
   
   1. `chore(deps): move ngx-translate to 18`: `package.json` and the lockfile, 
just the two packages.
   2. `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).
   3. `refactor(i18n): replace TranslateModule imports`: 233 files, mechanical.
   4. `test(i18n): migrate translation test providers`: 56 files, mechanical.
   5. and 6. `app.component.ts` and 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
   
   - Moving components from `| translate` to 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-loader` is not imported anywhere since 
`DeploymentTranslateLoader` replaced it (d5c8a59f). 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
   
   <!-- List what you ran and what you checked. Note whether the UI was 
exercised with mocks, a real Fineract backend, or both. -->
   
   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 build` was.
   
   - `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 existing `header.component` style budget warning.
   - `npm run test:unit`: 266 files, 1753 tests pass, the same counts as before 
the change.
   - `npm ci --dry-run` resolves from the lockfile; `npm audit 
--audit-level=high --omit=dev`: 0 vulnerabilities; `license-checker` with the 
allowed list and `scripts/check-license.sh`: pass.
   - Mocked Playwright project, whole: 408 passed, 1 skipped, 1 failed. The 
failure is `loan-product-down-payment.spec.ts` "down payment is offered only 
for a progressive product": the shared `selectOption` helper 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.
   - `mobile` project: 25 passed, 5 skipped (viewport guards).
   - A manual runtime check, not committed: sign in, switch the language to 
Hindi (the sidebar re-renders in Hindi), switch back to English (it returns to 
the original text), with no ngx-translate or Angular warning or error in the 
console, and the login button reading words rather than `login.submit`.
   
   ## Screenshots
   
   <!-- Add screenshots or a short recording for UI changes. Write "Not 
applicable" for non-UI changes. -->
   
   Not applicable. No visible change; the rendered text is the same.
   
   ## AI assistance (optional)
   
   <!-- If generative AI materially assisted this contribution, optionally 
state the tool or model and
   the harness or workflow used. The contributor remains responsible for the 
submitted change. -->
   
   - Tool / model:
   - Harness / workflow:
   
   ## Checklist
   
   <!-- Check each item, or explain why it does not apply. -->
   
   - [x] I did not hand-edit generated files under `src/app/api/`.
   - [x] New component or service code uses the adapter boundary in 
`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.)
   - [x] User-facing strings use translation keys. (No strings added or 
changed.)
   - [x] I added or updated tests appropriate to this change, or explained why 
tests were not needed. (The missing-translation handler's spec is rewritten for 
the new API; the rest of the suite is the check.)
   - [ ] UI workflow changes include suitable e2e coverage, including 
real-backend testing where relevant. (No UI workflow changes. The mocked and 
mobile suites ran; the real-backend suite did not, see Verification.)
   - [x] Commits are signed — see [Commit 
Signing](CONTRIBUTING.md#commit-signing) in CONTRIBUTING.md.
   - [ ] I followed the [AI-assisted contributions 
guidance](CONTRIBUTING.md#ai-assisted-contributions).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to