Skip to content

i18n(zh-CN): translate Volcano dashboard UI section into Chinese#254

Open
aryunewaskar77-art wants to merge 3 commits into
volcano-sh:mainfrom
aryunewaskar77-art:feature/add-i18n-chinese-support
Open

i18n(zh-CN): translate Volcano dashboard UI section into Chinese#254
aryunewaskar77-art wants to merge 3 commits into
volcano-sh:mainfrom
aryunewaskar77-art:feature/add-i18n-chinese-support

Conversation

@aryunewaskar77-art
Copy link
Copy Markdown

Summary

This PR adds Chinese (Simplified) localization support for Volcano Dashboard using react-i18next, enabling seamless switching between English and Chinese across the UI.

Changes

Localization framework

  • Added react-i18next integration with a dedicated i18n.js configuration.
  • Centralized translations under:
frontend/public/locales/en/translation.json
frontend/public/locales/zh/translation.json
  • Integrated localization support application-wide.

Language support

  • English (en) remains the default language.
  • Added Chinese (Simplified) (zh) support.
  • Added a persistent language switcher in the sidebar for instant language changes.

Translation improvements

  • Standardized Kubernetes terminology:

    • Pods → Pods
    • PodGroups → PodGroups
    • Age → 存活时间
  • Preserved Kubernetes ecosystem terminology where appropriate for better usability.

Dynamic UI localization

Implemented localization support for:

  • Pagination labels and counts using interpolation
  • Reactive error messages
  • Create Resource dialogs
  • Dynamic status labels
  • Form field labels and validation messages

Examples:

English:
Total Pods: 10

Chinese:
Pods 总数:10

Error messages now update instantly when switching languages without requiring a page refresh.

Additional improvements

  • Removed duplicate localization keys
  • Standardized naming conventions
  • Kept raw Kubernetes YAML content in English to preserve system behavior and readability

Screenshots

Before

Screenshot 2026-05-17 at 12 11 10 AM Screenshot 2026-05-17 at 12 12 01 AM

After

Screenshot 2026-05-17 at 12 12 37 AM Screenshot 2026-05-17 at 12 12 58 AM

Testing

Verified:

  • Language switching updates UI immediately
  • Dynamic counts interpolate correctly
  • Error messages reactively update
  • Resource creation dialogs render localized labels correctly
  • Existing dashboard functionality remains unchanged

Signed-off-by: aryunewaskar77-art <aaryaanewaskar@gmail.com>
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jessestutler for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @aryunewaskar77-art! It looks like this is your first PR to volcano-sh/dashboard 🎉

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements internationalization (i18n) across the Volcano Dashboard using i18next and react-i18next, introducing support for English and Chinese. Hardcoded strings in components, charts, and dialogs have been replaced with translation keys, and a language toggle has been added to the main layout. Review feedback identifies inconsistent error handling in Pods.jsx, missing translation keys for queue YAML titles and general YAML labels, and a fragile language detection check. Additionally, there are notes regarding a missing placeholder in the pod_details_title translation key and a suggestion to localize resource names in the QueueTableHeader instead of using simple capitalization.

Comment thread frontend/src/components/pods/Pods.jsx Outdated
@@ -185,7 +187,7 @@ const Pods = () => {
<Typography variant="body1">{error}</Typography>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Inconsistent error handling: In this component, error is set as a string (lines 56, 156), but the rendering logic in other components (like Jobs.jsx or Queues.jsx) expects an object with key and message properties. If error becomes an object here, this line will render [object Object]. Consider using the ErrorDisplay component for consistency.

            {error && (
                <Box sx={{ mt: 2, color: theme.palette.error.main }}>
                    <Typography variant="body1">
                        {error.key ? `${t(error.key)}${error.message}` : error}
                    </Typography>
                </Box>
            )}

"state": "State",
"guarantee_resources_optional": "Guarantee Resources (Optional)",
"capability_resources_optional": "Capability Resources (Optional)",
"deserved_resources_optional": "Deserved Resources (Optional)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The key queue_yaml_title is missing from the English translation file, but it is being used in frontend/src/components/queues/QueueYamlDialog.jsx. This will cause the raw key to be displayed in the UI.

Suggested change
"deserved_resources_optional": "Deserved Resources (Optional)"
"deserved_resources_optional": "Deserved Resources (Optional)",
"queue_yaml_title": "Queue YAML - {{selectedQueueName}}",
"yaml": "YAML"
}

"state": "状态",
"guarantee_resources_optional": "保证资源(可选)",
"capability_resources_optional": "能力资源(可选)",
"deserved_resources_optional": "应得资源(可选)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The keys queue_yaml_title and yaml are missing from the Chinese translation file. Please add them to ensure the UI is fully localized.

Suggested change
"deserved_resources_optional": "应得资源(可选)"
"deserved_resources_optional": "应得资源(可选)",
"queue_yaml_title": "队列 YAML - {{selectedQueueName}}",
"yaml": "YAML"
}

Comment thread frontend/src/components/Layout.jsx Outdated
}
sx={{ color: "white" }}
>
{i18n.language === "en" ? "中文" : "EN"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Checking i18n.language === "en" is fragile because the language detector might return regional variants like en-US. It is safer to check if the language starts with en or use i18n.resolvedLanguage.

Suggested change
{i18n.language === "en" ? "中文" : "EN"}
{i18n.language.startsWith("en") ? "中文" : "EN"}

@@ -26,7 +28,7 @@ const PodDetailsDialog = ({ open, podName, podYaml, onClose }) => {
},
}}
>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pod_details_title translation key in translation.json does not contain the {{podName}} placeholder, so the podName passed here will not be rendered. Please update the translation files to include the placeholder.

sx={{ letterSpacing: "0.02em" }}
>
{`Allocated ${field}`}
{`${field.toUpperCase()}${t("allocated_suffix")}`}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Resource names (like cpu, memory, nvidia.com/gpu) should be localized using t() instead of just calling toUpperCase(). This ensures consistency with other parts of the UI like QueueResourcesBarChart.jsx.

Suggested change
{`${field.toUpperCase()}${t("allocated_suffix")}`}
{`${t(field.toLowerCase())}${t("allocated_suffix")}`}

…Dashboard

- Initialize react-i18next and configure EN/ZH translation infrastructure
- Localize Dashboard, Jobs, Pods, Queues, and PodGroups views
- Add persistent language switcher with robust language detection
- Implement interpolation-based dynamic resource count translations
- Refactor error handling for reactive language updates
- Standardize Kubernetes terminology and dynamic labels
- Localize resource creation dialogs and dynamic placeholders
- Clean up duplicate keys and improve translation consistency

Signed-off-by: aryunewaskar77-art <aaryaanewaskar@gmail.com>
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants