feat: comprehensive localization (zh-CN) and UI/UX polish for resource views#272
feat: comprehensive localization (zh-CN) and UI/UX polish for resource views#272rabbitc0der wants to merge 1 commit into
Conversation
|
[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 @rabbitc0der! It looks like this is your first PR to volcano-sh/dashboard 🎉 |
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized translation system for the Volcano Dashboard, enabling support for both English and Simplified Chinese. Hardcoded strings across various components, including charts, tables, and dialogs, have been replaced with localized strings from a new translations.js configuration file. Additionally, minor dependency metadata cleanups were performed in package-lock.json. The review feedback highlights opportunities to further improve the implementation by ensuring all error messages and resource labels consistently utilize the new translation object for better maintainability.
| <Typography color="error" sx={{ mb: 2 }}> | ||
| 获取 Pods 失败: 请求失败, 状态码 {String(error)} | ||
| </Typography> |
There was a problem hiding this comment.
The error message is hardcoded in Chinese. Please use the translations object to ensure the application remains localizable and consistent.
| <Typography color="error" sx={{ mb: 2 }}> | |
| 获取 Pods 失败: 请求失败, 状态码 {String(error)} | |
| </Typography> | |
| <Typography color="error" sx={{ mb: 2 }}> | |
| {translations.zh.errorFetchPods}: {String(error)} | |
| </Typography> |
| const allocatedFieldLabelMap = { | ||
| cpu: "已分配 CPU", | ||
| memory: "已分配 内存", | ||
| pods: "已分配 Pod", | ||
| }; |
There was a problem hiding this comment.
The allocatedFieldLabelMap object contains hardcoded Chinese strings. These should be moved to the translations.js file and accessed via the translations object to support multi-language support.
| const allocatedFieldLabelMap = { | |
| cpu: "已分配 CPU", | |
| memory: "已分配 内存", | |
| pods: "已分配 Pod", | |
| }; | |
| const allocatedFieldLabelMap = { | |
| cpu: translations.zh.cpu, | |
| memory: translations.zh.memory, | |
| pods: translations.zh.pods, | |
| }; |
| const getResourceDisplayLabel = (resource) => { | ||
| switch (resource) { | ||
| case "cpu": | ||
| return "CPU 资源"; | ||
| case "memory": | ||
| return "内存资源"; | ||
| case "pods": | ||
| return "Pod 资源"; | ||
| case "nvidia.com/gpu": | ||
| return "GPU 资源"; | ||
| default: | ||
| return `${resource.charAt(0).toUpperCase() + resource.slice(1)} 资源`; | ||
| } | ||
| }; |
There was a problem hiding this comment.
The getResourceDisplayLabel function contains hardcoded Chinese strings. Please move these to the translations.js file and use the translations object to support dynamic language switching.
const getResourceDisplayLabel = (resource) => {
return translations.zh[resource] || `${resource.charAt(0).toUpperCase() + resource.slice(1)} 资源`;
};5292e39 to
836ec06
Compare
…lified Chinese Signed-off-by: rabbitc0der <vithallomate@gmail.com>
836ec06 to
9c2653a
Compare
feat: comprehensive localization (zh-CN) and UI/UX polish for resource views
I. Overview
This Pull Request completes the prerequisite task for the LFX Mentorship 2026 Term 2 project: "Scheduler Management, Observability & Log Explorer UI." While the primary goal was the translation of UI sections into Chinese, I treated this task as an opportunity to perform a deep audit of the Dashboard’s current resource observability. I have implemented a system-wide localization for the Dashboard, Jobs, Queues, Pods, and PodGroups sections, ensuring that the interface is accessible to the Chinese-speaking CNCF community while maintaining technical consistency with Kubernetes standards.
II. The Journey: Phase-wise Implementation
Phase 0: Frontend-First Baseline & UI Mapping
I initially deployed the dashboard in a frontend-only standalone mode. This allowed me to map the entire UI hierarchy and identify static English strings without the complexity of backend data. By starting with this "mock" baseline, I was able to create the
translations.jsframework and verify the layout's responsiveness to Chinese characters before integrating real-time cluster data.Phase 1: Environment & Observability Audit
Then, I began by deploying a local development environment using
k3dand a mock-cluster to understand how the dashboard consumes data. I identified several "hardcoded" English strings within the charts and table rows that were not just language barriers but also inconsistent with standard Chinese technical nomenclature.Phase 2: Scalable Localization Architecture
Instead of using "quick-fix" string replacements, I implemented a centralized configuration strategy:
frontend/src/config/translations.jsto serve as a single source of truth. This ensures that as the proposed/schedulersection is built, future contributors can easily add new keys.statusMaplogic to translate backend states (e.g., Running, Pending) into Chinese labels (e.g., 运行中, 等待中) without breaking the Material UI theme logic or the underlying Kubernetes API contracts.Phase 3: Deep-Dive Implementation (The "Five Pillars")
Phase 4: Locale-Standard Formatting
Beyond word translation, I updated the data presentation:
zh-CNlocale standard (YYYY/MM/DD HH:mm:ss) usingtoLocaleString().kube-systemandvolcano-systemfor technical accuracy.III. Technical Challenges & Solutions
The "Status-Color" Conflict
Consistent Date Presentation
IV. Learnings
Through this task, I gained a deeper understanding of:
JobStatusChipto support multi-language labels.V. Alignment with Project Goals
This PR sets the stage for the proposed Scheduler Observability work. By localizing the core resource views, I have ensured that the upcoming Metrics Tab and Log Explorer can be built upon a foundation that supports internationalization (i18n) from day one. I am particularly excited about the Logs Tab proposal, as I’ve already explored the
CoreV1Apiduring this task to understand how logs are currently fetched.VI. Visual Evidence (Testing in Cluster)
📷 Main Resource Views (10 Images)
📝 Creation Dialogs (4 Images)
🔍 UI Detail & Logic (In all 10 Images uploaded earlier)