tju-yxq opened a new pull request, #5583:
URL: https://github.com/apache/rocketmq-dashboard/pull/5583
### Which Issue(s) This PR Fixes
- Fixes #5582
### Brief Description
Routes the axios interceptor's two hardcoded Chinese fallbacks through the
shared translation table:
- **`api/client.ts`**: a small `translate(key)` helper resolves the
persisted language preference via `getInitialLanguage()` and looks up
`translations[key][lang]` — called at error time, so a language switch takes
effect on the next error with no React coupling. The business-error fallback
becomes `common.requestFailed`; the CORS rejection hint becomes
`common.corsRejectionHint` (the const becomes a function so the language is
read at use time, and the `error.message` rewrite uses the same resolved
string).
- **`translations.ts`**: two new `common.*` keys; the zh text is
byte-identical, and the CORS hint gains an English rendering for the first time.
### How Did You Test This Change?
```
cd web && npx vitest run src/App.test.tsx
Test Files 1 passed (1)
Tests 8 passed (8) # the App suite exercises the client
interceptor's auth and error paths
cd web && npx eslint src/api/client.ts src/i18n/translations.ts
(no output — 0 errors, 0 warnings)
cd web && npx tsc --noEmit
(no output — exit 0)
```
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in (one
interceptor, two fallbacks, per the shared-translation theme)
- [x] Commit subject follows Conventional Commits
- [ ] Tests added or updated for non-trivial changes, test methods named
`...Test` (display-string replacement; the zh render is byte-identical and the
App suite covers the interceptor)
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(two new `common.*` keys)
- [x] Architecture constraints stay green (no Java changes)
- [x] New source files carry the ASF license header (no new source files)
- [ ] Documentation touched where behaviour changed (error display text only)
--
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]