You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Wang1rrr (via GitHub)" <gi...@apache.org> on 2026/09/22 00:05:56 UTC
[PR] fix(web): localize the remaining hardcoded strings on the audit page [rocketmq-dashboard]
Wang1rrr opened a new pull request, #4802:
URL: https://github.com/apache/rocketmq-dashboard/pull/4802
### Which Issue(s) This PR Fixes
No issue - follows the same localization pass as #4621, #4629 and #4633.
### Brief Description
`web/src/pages/ops/audit.tsx` reads every other label through `useLang()`, but five strings were still literals, so an English console showed Chinese text:
| line | literal | now |
| --- | --- | --- |
| 166 | record-list load failure toast | `audit.loadFailed` |
| 225 | summary load failure toast | `audit.summaryLoadFailed` |
| 299 | cleanup failure toast | `audit.cleanupFailed` |
| 310 | export failure toast | `audit.exportFailed` |
| 580 | trailing half of the cleanup-days sentence | `audit.cleanupDaysSuffix` |
The four toasts are worded after `audit.timelineLoadFailed` / `audit.timelineExportFailed`, which already cover the resource-operation drawer that shares this page's export path. Two of them are used inside `useEffect`, so they are hoisted to stable strings and added to the dependency arrays - depending on `t` directly would refetch on every language-context render, which is what `Ops.tsx:46` already avoids the same way.
The cleanup modal built its sentence out of `t('audit.cleanup')` + `<InputNumber>` + a hardcoded tail. That rendered as an ungrammatical English fragment and repeated the word for "logs" twice in Chinese. It is now `audit.cleanupDaysPrefix` + `<InputNumber>` + `audit.cleanupDaysSuffix`, so each language puts the number where its grammar wants it, and the pair was split out of the existing `audit.cleanupDays` entry so the modal and the success toast describe the same action in the same words. `t('audit.cleanup')` keeps its other use as the toolbar button label.
The Chinese values are moved verbatim, not rewritten; only English text is new.
### How Did You Test This Change?
```
cd web
npx vitest run src/pages/ops/__tests__/AuditPage.test.tsx src/utils/download.test.ts
Test Files 2 passed (2)
Tests 15 passed (15)
npx tsc -b # exit 0
npx eslint src/pages/ops/audit.tsx src/i18n/translations.ts # exit 0
```
Baseline for reference, unchanged by this diff: `npm test` on the trunk gives 139 files / 1280 tests passing.
Also re-ran the dictionary reconciliation over every literal `t('...')` key in `web/src` against `translations.ts`: 1318 used keys, 0 missing, so the six new entries resolve and nothing else regressed.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / `refactor:` / `chore:` / `docs:` / `perf:`)
- [ ] Tests added or updated for non-trivial changes, test methods named `...Test` - the existing `AuditPage.test.tsx` covers the page; no assertion depended on the literals
- [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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(web): localize the remaining hardcoded strings on the audit page [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #4802: fix(web): localize the remaining hardcoded strings on the audit page
URL: https://github.com/apache/rocketmq-dashboard/pull/4802
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(web): localize the remaining hardcoded strings on the audit page [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #4802:
URL: https://github.com/apache/rocketmq-dashboard/pull/4802#issuecomment-5845587999
The five literals are still hardcoded on the trunk — `web/src/pages/ops/audit.tsx:166`, `:225`, `:299`, `:310` and `:580` — and your mapping is the right one: the toast wording matches the existing `audit.timelineLoadFailed` / `audit.timelineExportFailed`, and splitting the cleanup sentence into a prefix and a suffix is the only way to keep the `InputNumber` inside a translated sentence. Two things block it as it stands.
1. It no longer merges. `web/src/i18n/translations.ts` conflicts: #4825 landed and inserted `audit.summaryMatched` … `audit.summaryResourceTypes` at `:1591-1595`, immediately after `audit.cleanupSuccess` (`:1590`) — exactly where your six keys go. Please rebase onto the current `rocketmq-studio`.
2. There is no test, and nothing on the trunk would notice a regression. `web/src/pages/ops/__tests__/AuditPage.test.tsx` has 11 `it()` blocks and none of them switches the console language or asserts any of these strings (no `LANGUAGE_STORAGE_KEY`, no `message.error` assertion), so reverting any of your five edits leaves the suite green. Please add one English-console case following the pattern already merged in `AuditSummaryCards.test.tsx:77-87`: set the language to `en`, reject the record-list request and assert the toast text; then open the cleanup modal and assert `Clean logs older than` / `days` render and `天之前的日志` does not.
While you are in there: `audit.cleanupDays` (`translations.ts:1588`) has no remaining call site and your prefix/suffix pair supersedes it — drop it in the same change. A rebased version carrying that one test will merge.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(web): localize the remaining hardcoded strings on the audit page [rocketmq-dashboard]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4802:
URL: https://github.com/apache/rocketmq-dashboard/pull/4802#discussion_r4067463198
##########
web/src/pages/ops/audit.tsx:
##########
@@ -570,14 +576,14 @@ const AuditPage: React.FC = () => {
<Flex vertical gap={12}>
<Text>{t('audit.cleanupDesc')}</Text>
<Flex align="center" gap={8}>
- <span>{t('audit.cleanup')}</span>
+ <span>{t('audit.cleanupDaysPrefix')}</span>
Review Comment:
Could you add an English-mode assertion for this modal? `AuditPage.test.tsx` only renders the default Chinese UI and does not exercise the newly split prefix/suffix (or the new failure toasts), so an incorrect key/value or a regression to hardcoded Chinese would still pass the suite. Other localized page suites explicitly set `LANGUAGE_STORAGE_KEY` to `en` and assert English UI text.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org