Skip to content

Add independent i18n support for PlatformDashboard page / 为 PlatformDashboard 页面添加独立的国际化支持#523

Open
liaozip wants to merge 1 commit intodataelement:mainfrom
liaozip:feature/platfom-dashboard-i18n
Open

Add independent i18n support for PlatformDashboard page / 为 PlatformDashboard 页面添加独立的国际化支持#523
liaozip wants to merge 1 commit intodataelement:mainfrom
liaozip:feature/platfom-dashboard-i18n

Conversation

@liaozip
Copy link
Copy Markdown
Contributor

@liaozip liaozip commented May 5, 2026

描述 / Description

中文

为 PlatformDashboard 页面添加独立的中英文双语国际化支持,不依赖项目主 i18n 翻译文件,同时保持与项目语言切换机制的完美同步。

English

Add independent bilingual (English/Chinese) internationalization support for the PlatformDashboard page, without relying on the project's main i18n translation files, while maintaining perfect synchronization with the project's language switching mechanism.


变更内容 / Changes

序号 变更项 Description
1 移除依赖 Removed dependency on react-i18next's useTranslation hook
2 新建翻译系统 Created page-level translation system with TRANSLATIONS object
3 集成 i18n 实例 Integrated with project's i18n instance for language sync
4 替换硬编码文本 Replaced all hard-coded texts with translated versions
5 参数插值支持 Maintained parameter interpolation (e.g., {retainedInfo})
6 修复兼容性 Fixed TypeScript compatibility issue with replaceAll

技术实现 / Technical Implementation

核心方案

// 使用项目 i18n 实例获取当前语言
const currentLng = i18n.language;

// 监听语言变化事件
i18n.on('languageChanged', handleLanguageChanged);

翻译系统结构

const TRANSLATIONS = {
    en: { /* 英文翻译 */ },
    zh: { /* 中文翻译 */ }
};

修改文件 / Modified Files

  • frontend/src/pages/PlatformDashboard.tsx - 完整的页面级国际化实现

测试建议 / Testing Suggestions

  1. 语言切换测试

    • 在页面上切换中英文语言
    • 验证所有文本正确切换
  2. 页面功能测试

    • 验证所有图表、表格、按钮正常显示
    • 验证工具提示正常显示
  3. 动态内容测试

    • 验证参数插值功能正常工作
    • 验证 loading/no data 状态正确显示

兼容性 / Compatibility

  • ✅ 与项目现有语言切换机制完全兼容
  • ✅ 不影响其他页面的国际化
  • ✅ TypeScript 编译通过
  • ✅ 无需修改项目配置

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8827efad3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread PlatformDashboard.tsx
@@ -0,0 +1,706 @@
import React, { useState, useEffect, useCallback } from 'react';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Place i18n dashboard in the compiled frontend path

This commit adds a new PlatformDashboard component at the repository root, but the app still renders frontend/src/pages/PlatformDashboard.tsx (imported from frontend/src/pages/AdminCompanies.tsx) and the frontend TypeScript config only includes src (frontend/tsconfig.json). As a result, none of the new translation logic is actually bundled or executed, so the intended i18n behavior for the dashboard is not delivered.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant