Frun1na opened a new pull request, #4971:
URL: https://github.com/apache/rocketmq-dashboard/pull/4971
### Which Issue(s) This PR Fixes
<!-- Issue is filed right after this PR; the `Fixes` line is added once it
has a number. -->
### Brief Description
Two surfaces still rendered hardcoded Chinese with the English UI selected.
**Global API error handling (`web/src/api/client.ts`).** Both generic
failure paths were Chinese literals:
- a failed business envelope that carries no `message` was reported as
`请求失败`;
- a CORS rejection (Spring answers 403 with a plain-text body) was reported
as the Chinese `请求被服务端 CORS 策略拒绝…` hint.
The response interceptor is not a component, so it cannot read the language
context. It now translates through the persisted selection
(`getInitialLanguage()` reads `localStorage` on every call), which additionally
means a toast raised right after a language switch uses the language the user
just picked.
**Home page build stamp (`web/src/pages/home/index.tsx`).** The footer
printed `当前版本 <time> build(<commit>)` literally, while every other string on
that page (banner, greetings, tagline, docs/community/brand links, composer
placeholder) goes through `t()`. It now uses a `home.version` key with `{time}`
and `{commit}` parameters.
Chinese values are copied verbatim from the literals they replace, so the
Chinese UI is byte-for-byte unchanged.
### How Did You Test This Change?
Both new tests fail without the source change and pass with it (mutation
check, run on this branch):
```
$ cd web && npx vitest run src/api/client.test.ts -t "persisted language"
# with web/src/api/client.ts restored to the base revision:
Tests 1 failed | 14 skipped (15)
# with the change applied:
✓ src/api/client.test.ts (15 tests) 30ms
$ cd web && npx vitest run src/pages/home/__tests__/HomePage.test.tsx -t
"build stamp"
# with web/src/pages/home/index.tsx restored:
Tests 1 failed | 9 skipped (10)
# with the change applied:
✓ src/pages/home/__tests__/HomePage.test.tsx (10 tests) 1128ms
```
Suites around the changed modules:
```
$ cd web && npx vitest run src/api src/pages/home src/i18n
Test Files 35 passed (35)
Tests 272 passed (272)
```
Lint and type-check of the whole `web` app:
```
$ cd web && npx eslint src/api/client.ts src/pages/home/index.tsx
src/i18n/translations.ts \
src/api/client.test.ts src/pages/home/__tests__/HomePage.test.tsx
# no output
$ cd web && npx tsc --noEmit -p tsconfig.app.json
# no output
```
No backend code is touched; `server` tests were not run.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) — no backend files changed
- [x] New source files carry the ASF license header — no new source files
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help) — no user-visible contract change beyond the added translations
--
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]