Aman-Mittal opened a new pull request, #625:
URL: https://github.com/apache/fineract-backoffice-ui/pull/625
## What and why
A translation key that does not resolve renders as its own name, with
nothing in the console and nothing in CI. `check-translations.mjs` was the
guard against that, and it saw less than it appeared to.
Closes #624
### The blind spot
`` `\| translate` `` does not match `` `\| appTranslate` `` — the pipe ADR
0003 mandates — and nothing matched `i18n.translate('KEY')` or a nav entry's
`labelKey`. That is ~800 references. The script reported **1621** checked keys;
it now reports **2034**.
The first thing the widened check found was a defect that had been on screen
the whole time: three top-level sidebar groups held `labelKey: 'Admin'`,
`'Campaigns'` and `'Interop'` — the English words, in a field named for a key.
They render exactly like a working entry in English and stay English in Hindi
and Korean. Fixed in the first commit, separately from the checks.
### What this adds
Four static checks, all inside CI jobs that already run, so no extra CI time:
| Check | Catches | Violations today |
| ----- | ------- | ---------------- |
| `MISSING` (widened) | a referenced key `en.json` does not define | 0 |
| `UNWRAPPED` (new) | `{{ 'COMMON.SAVE' }}` — a key interpolated with no
translate pipe | 0 |
| `CATALOGUES` (new) | `hi`/`ko` defining a key `en.json` dropped, or
coverage regressing | 1, fixed here |
| `check:nav-ids` (extended) | a `labelKey` that is not a translation key |
3, fixed here |
Coverage is a **ratchet, not a threshold**. `hi` and `ko` cover 469 of 2505
keys; filling a partial catalogue is translator work and must never block a UI
change. `scripts/i18n-coverage.json` records the floor — the same idiom as
`scripts/nav-ids.json` — so the only failure is going backwards.
### And one runtime check
None of the four can see a key assembled at runtime, and several exist:
```ts
this.i18n.translate(`SAVINGS.CONFIRM_${key}`)
this.i18n.translate(`GROUPS.CMD_${command.toUpperCase()}`)
```
A branch of one of those with no key prints the key, and only the browser
knows. So `ReportingMissingTranslationHandler` reports an unresolved key in a
dev build, and the `failOnMissingTranslations` fixture fails the Playwright
test that produced it. The handler returns the key exactly as ngx-translate
already does, so **nothing a user sees changes**.
Two things keep that from becoming noise, and they are why it is safe to
enable while the non-English catalogues are 19% complete:
- It stays silent until the current language's catalogue has loaded. Every
key misses during startup — the state `app.config.ts` describes at length,
where the login button reads `login.submit`.
- ngx-translate consults the fallback catalogue *before* calling the handler
(`TranslateStore.getTranslation`), so a key present in `en` but absent from
`hi` is never reported. Only a key missing from both is.
The fixture enforces by default, unlike the change-detection one beside it,
which reports because it inherited a backlog. This one has none to inherit.
`ALLOW_I18N_MISSES=1` downgrades it for a local run against a half-translated
feature.
## Verification
- `npm run lint` — clean
- `npm run format:check` — clean
- `npm run test:unit` — **1576 passed** (251 files), including 5 new tests
for the handler
- `npm run typecheck:e2e` — clean
- `npm run i18n:check` — all three checks pass
- `npm run check:nav-ids` — passes; verified it *fails* by reverting one
label to `'Admin'`
- `npx playwright test --project=mocked
e2e/all-functions-read-shortcut.spec.ts` — 5 passed. Before the nav fix, this
spec failed 4 tests naming `Admin`, `Campaigns` and `Interop`, which is how the
defect was found.
- Full mocked Playwright suite: **running at the time of opening this PR.**
I will confirm the result in a comment; if it surfaces further unresolved keys,
they are either real defects to fix here or the fixture default changes to
warn-first.
### Known limitation
The runtime gate only sees what the e2e suite actually exercises. A
dynamically-built key behind an action no spec clicks stays uncovered. It
narrows the gap rather than closing it.
## Screenshots
Not applicable — no visual change. The three sidebar groups render
identically in English; the change is that they can now be translated at all.
--
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]