Wang1rrr opened a new pull request, #4806:
URL: https://github.com/apache/rocketmq-dashboard/pull/4806

   ### Which Issue(s) This PR Fixes
   
   No issue - continues the localization pass from #4621, #4629, #4633, #4802 
and #4803.
   
   ### Brief Description
   
   `web/src/layouts/MainLayout.tsx` already resolves every `nav.*`, `layout.*` 
and `user.*` label through `useLang()`, but seven strings were still literals, 
so an English console mixed languages:
   
   | line | literal | now |
   | --- | --- | --- |
   | 112 | toast when the server-side logout call fails | `user.logoutFailed` 
(new) |
   | 274 | `/studio/users` breadcrumb entry | `userMgmt.title` (existing) |
   | 334 | admin user-menu item | `userMgmt.title` (existing) |
   | 799 | navigation-palette empty description | `layout.noMatchingPage` (new) 
|
   | 819 | arrow-key hint | `layout.shortcutNavigate` (new) |
   | 823 | enter-key hint | `common.open` (new, sibling of the existing 
`common.close`) |
   | 827 | esc-key hint | `common.close` (existing) |
   
   Two of the seven already had dictionary entries carrying the identical 
Chinese value, so they are pointed at those entries instead of getting 
duplicate keys - the script that made the change asserts the extracted literal 
equals the existing entry's `zh` value before reusing it. Only 
`user.logoutFailed` is genuinely new copy; the Chinese for all four new keys is 
moved verbatim out of the component.
   
   The language toggle at line 556 (`lang === 'zh' ? 'En' : ...`) is 
deliberately untouched: rendering the name of the language being switched *to* 
is the point of that control, not an untranslated string.
   
   ### How Did You Test This Change?
   
   Added `reports a failed server logout in the language the console is in` to 
`MainLayout.test.tsx`: it sets the stored language preference to `en`, rejects 
the mocked `logout`, clicks the localized logout button and asserts 
`message.warning` was called with `translations['user.logoutFailed'].en`. 
Reading the expectation from the dictionary keeps the test free of literals and 
fails if the toast ever goes back to being a hardcoded string.
   
   ```
   cd web
   npx vitest run src/layouts/MainLayout.test.tsx
    Test Files  1 passed (1)
         Tests  5 passed (5)          # was 4 before this change
   
   npx tsc -b                                        # exit 0
   npx eslint src/layouts/MainLayout.tsx src/layouts/MainLayout.test.tsx 
src/i18n/translations.ts   # exit 0
   npx prettier --check <the three files>            # All matched files use 
Prettier code style!
   ```
   
   Baseline for reference, unchanged by this diff: `npm test` on the trunk 
gives 139 files / 1280 tests passing.
   
   ### 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/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks) - N/A, frontend only
   - [ ] New source files carry the ASF license header - N/A, no new files
   - [ ] Documentation touched where behaviour changed - N/A, no documented 
contract changed
   


-- 
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