feat(i18n): Translate Dashboard UI into Simplified Chinese#249
Conversation
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
Signed-off-by: pggdev <princegupta.ns153@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @pggdev! It looks like this is your first PR to volcano-sh/dashboard 🎉 |
There was a problem hiding this comment.
Code Review
This pull request implements internationalization (i18n) for the Volcano Dashboard using react-i18next, introducing support for English and Chinese. Multiple components, including JobStatusPieChart, QueueResourcesBarChart, and the main Dashboard, were refactored to replace hardcoded strings with translation keys, and Dashboard.jsx was updated to wrap data fetching in useCallback. Feedback identifies an improvement opportunity in QueueResourcesBarChart.jsx to simplify the getResourceLabel function by utilizing the existing resourceTranslationKeys mapping instead of a redundant switch statement.
| const getResourceLabel = (resource) => { | ||
| switch (resource) { | ||
| case "memory": | ||
| return t("dashboard.charts.queueResources.resourceNames.memory"); | ||
| case "cpu": | ||
| return t("dashboard.charts.queueResources.resourceNames.cpu"); | ||
| case "pods": | ||
| return t("dashboard.charts.queueResources.resourceNames.pods"); | ||
| case "nvidia.com/gpu": | ||
| return t("dashboard.charts.queueResources.resourceNames.gpu"); | ||
| default: | ||
| return resource.toUpperCase(); | ||
| } | ||
| }; |
There was a problem hiding this comment.
The getResourceLabel function uses a switch statement that duplicates logic already present in the resourceTranslationKeys mapping. To improve maintainability and ensure consistency, you should use the mapping object instead of a switch statement.
const getResourceLabel = (resource) => {
const key = resourceTranslationKeys[resource];
return key
? t(`dashboard.charts.queueResources.resourceNames.${key}`)
: resource.toUpperCase();
};
Part of #243
Summary
Add i18next-based internationalization support for the Dashboard section and include English and Simplified Chinese translation resources.
Changes
Scope
This PR only covers the Dashboard translations.
Manual verification can be done by setting
i18nextLngin localStorage toenorzh-CN. A language switcher will be added in a follow-up PR to make this easier from the UI.ScreenShots
Verification
npm run lint -w frontendnpm run test -w frontend -- --runnpm run build -w frontend