tju-yxq opened a new pull request, #5579:
URL: https://github.com/apache/rocketmq-dashboard/pull/5579

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5578
   
   ### Brief Description
   
   Closes the two leftover i18n gaps in the shared utils layer:
   
   - **`timeZone.ts`**: the parse and DST-gap failures now throw a dedicated 
`TimeFormatError` carrying a translation key plus params 
(`timeZone.invalidLocalDateTime` / `timeZone.nonexistentLocalDateTime`), 
instead of hardcoded English strings. The class is exported for `instanceof` 
checks.
   - **`systemAlerts.tsx`** (silence form catch): resolves `TimeFormatError` 
through `t(error.key, error.params)` and keeps the raw-message fallback for any 
other error, so the form's validation toast follows the display language. The 
zh error text becomes `本地时间 {value} 在时区 {timeZone} 不存在`, matching the form's 
language.
   - **`UserManagement.tsx`**: the session table's `durationText` moves into 
the component and passes the console `lang` to `formatDelay`, fixing durations 
that always rendered Chinese regardless of the display language.
   - **`translations.ts`**: two new `timeZone.*` keys.
   - **`timeZone.test.ts`**: the two throw assertions check the new keys.
   
   ### How Did You Test This Change?
   
   ```
   cd web && npx vitest run src/utils/timeZone.test.ts
    Test Files  1 passed (1)
         Tests  7 passed (7)   # throw assertions updated to the new keys
   
   cd web && npx vitest run src/pages/studio/__tests__/UserManagement.test.tsx 
src/pages/ops/__tests__/SystemAlertsPage.test.tsx
    Test Files  2 passed (2)
         Tests  30 passed (30)   # including 'shows maintenance windows and 
creates a scoped silence'
                                   # (the silence-form path that surfaces 
TimeFormatError) and
                                   # 'renders the page in English when the 
stored language preference is en'
   
   cd web && npx eslint src/utils/timeZone.ts src/pages/ops/systemAlerts.tsx 
src/pages/studio/UserManagement.tsx src/i18n/translations.ts
    0 errors (1 pre-existing warning)
   
   cd web && npx tsc --noEmit
   (no output — exit 0)
   ```
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in (the 
utils-layer language gaps — one thrown-error contract + one missing argument, 
per the key-returning theme)
   - [x] Commit subject follows Conventional Commits
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test` (timeZone test updated to the new error shape; both affected page 
suites pass)
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
(two new `timeZone.*` 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]

Reply via email to