247 lines
7.4 KiB
Markdown
247 lines
7.4 KiB
Markdown
# 多语言支持实现状态
|
||||
|
|
|
|||
|
|
## ✅ 已完成的工作
|
|||
|
|
|
|||
|
|
### 后端部分(100% 完成)
|
|||
|
|
|
|||
|
|
#### 1. 核心框架 ✅
|
|||
|
|
- ✅ 创建语言资源文件(messages_zh_CN.properties, messages_zh_TW.properties, messages_en.properties)
|
|||
|
|
- ✅ 配置 MessageSource Bean(MessageSourceConfig.kt)
|
|||
|
|
- ✅ 创建 LocaleInterceptor 拦截器
|
|||
|
|
- ✅ 修改 ErrorCode 枚举,添加 messageKey 字段(100+ 条错误消息)
|
|||
|
|
- ✅ 修改 ApiResponse.error() 方法,支持多语言
|
|||
|
|
- ✅ 创建 MessageUtils 工具类
|
|||
|
|
- ✅ 更新 WebMvcConfig,注册 LocaleInterceptor
|
|||
|
|
|
|||
|
|
#### 2. Controller 更新 ✅(全部完成)
|
|||
|
|
- ✅ AccountController - 完全更新
|
|||
|
|
- ✅ AuthController - 完全更新
|
|||
|
|
- ✅ LeaderController - 完全更新
|
|||
|
|
- ✅ UserController - 完全更新
|
|||
|
|
- ✅ CopyTradingController - 完全更新
|
|||
|
|
- ✅ CopyTradingTemplateController - 完全更新
|
|||
|
|
- ✅ MarketController - 完全更新
|
|||
|
|
- ✅ CopyTradingStatisticsController - 完全更新(包含 CopyOrderTrackingController)
|
|||
|
|
- ✅ ProxyConfigController - 完全更新
|
|||
|
|
- ✅ HealthController - 无需更新(无错误响应)
|
|||
|
|
|
|||
|
|
#### 3. 编译状态 ✅
|
|||
|
|
- ✅ 后端编译通过,无错误
|
|||
|
|
- ✅ 所有 ApiResponse.error() 调用都已传入 messageSource 参数
|
|||
|
|
|
|||
|
|
### 前端部分(部分完成)
|
|||
|
|
|
|||
|
|
#### 1. 核心框架 ✅
|
|||
|
|
- ✅ 安装 i18next 和 react-i18next 依赖
|
|||
|
|
- ✅ 配置 i18n(语言检测、资源加载)
|
|||
|
|
- ✅ 创建语言包文件结构(zh-CN, zh-TW, en)
|
|||
|
|
- ✅ 在 api.ts 中添加语言 Header(X-Language)
|
|||
|
|
- ✅ 在 main.tsx 中初始化 i18n
|
|||
|
|
|
|||
|
|
#### 2. 页面更新 ✅(2个页面已完成)
|
|||
|
|
- ✅ AccountDetail.tsx - 完全使用 i18n
|
|||
|
|
- ✅ App.tsx - 订单推送通知已使用 i18n,Ant Design locale 已配置
|
|||
|
|
- ✅ Login.tsx - 完全使用 i18n
|
|||
|
|
|
|||
|
|
#### 3. 语言包扩展 ✅
|
|||
|
|
- ✅ 添加了登录相关翻译(login.*)
|
|||
|
|
- ✅ 添加了订单相关翻译(order.*)
|
|||
|
|
- ✅ 添加了账户相关翻译(account.*)
|
|||
|
|
- ✅ 添加了通用翻译(common.*)
|
|||
|
|
|
|||
|
|
#### 4. 编译状态 ✅
|
|||
|
|
- ✅ 前端编译通过,无错误
|
|||
|
|
- ⚠️ 有 5 个 TypeScript linter 警告(文件存在,可能是缓存问题)
|
|||
|
|
|
|||
|
|
## ⏳ 待完成的工作
|
|||
|
|
|
|||
|
|
### 前端部分(21个页面待更新)
|
|||
|
|
|
|||
|
|
需要更新以下页面组件,使用 `useTranslation` Hook 替换硬编码文本:
|
|||
|
|
|
|||
|
|
1. AccountList.tsx
|
|||
|
|
2. AccountImport.tsx
|
|||
|
|
3. AccountEdit.tsx
|
|||
|
|
4. LeaderList.tsx
|
|||
|
|
5. LeaderAdd.tsx
|
|||
|
|
6. LeaderEdit.tsx
|
|||
|
|
7. TemplateList.tsx
|
|||
|
|
8. TemplateAdd.tsx
|
|||
|
|
9. TemplateEdit.tsx
|
|||
|
|
10. CopyTradingList.tsx
|
|||
|
|
11. CopyTradingAdd.tsx
|
|||
|
|
12. CopyTradingStatistics.tsx
|
|||
|
|
13. CopyTradingBuyOrders.tsx
|
|||
|
|
14. CopyTradingSellOrders.tsx
|
|||
|
|
15. CopyTradingMatchedOrders.tsx
|
|||
|
|
16. PositionList.tsx
|
|||
|
|
17. OrderList.tsx
|
|||
|
|
18. Statistics.tsx
|
|||
|
|
19. UserList.tsx
|
|||
|
|
20. ResetPassword.tsx
|
|||
|
|
21. SystemSettings.tsx
|
|||
|
|
22. ConfigPage.tsx
|
|||
|
|
|
|||
|
|
### 语言包扩展
|
|||
|
|
|
|||
|
|
根据页面内容,可能需要添加更多翻译键:
|
|||
|
|
- Leader 相关翻译
|
|||
|
|
- Template 相关翻译
|
|||
|
|
- CopyTrading 相关翻译
|
|||
|
|
- Position 相关翻译
|
|||
|
|
- Statistics 相关翻译
|
|||
|
|
- 等等
|
|||
|
|
|
|||
|
|
## 测试建议
|
|||
|
|
|
|||
|
|
### 后端测试
|
|||
|
|
1. ✅ 编译通过
|
|||
|
|
2. ⏳ 测试不同语言 Header 下的错误消息显示
|
|||
|
|
3. ⏳ 测试默认语言(无 Header 时)
|
|||
|
|
|
|||
|
|
### 前端测试
|
|||
|
|
1. ✅ 编译通过
|
|||
|
|
2. ⏳ 测试系统语言自动检测
|
|||
|
|
3. ⏳ 测试语言切换(如果添加了切换功能)
|
|||
|
|
4. ⏳ 测试不同语言下的页面显示
|
|||
|
|
5. ⏳ 测试 API 请求是否正确传递语言 Header
|
|||
|
|
|
|||
|
|
## 使用说明
|
|||
|
|
|
|||
|
|
### 后端
|
|||
|
|
所有 Controller 已更新,错误消息会自动根据 HTTP Header `X-Language` 或 `Accept-Language` 返回对应语言。
|
|||
|
|
|
|||
|
|
### 前端
|
|||
|
|
已更新的页面会自动根据系统语言显示对应文本。其他页面需要逐步更新。
|
|||
|
|
|
|||
|
|
## 下一步
|
|||
|
|
|
|||
|
|
1. 逐步更新剩余的前端页面组件
|
|||
|
|
2. 根据页面内容扩展语言包
|
|||
|
|
3. 全面测试多语言功能
|
|||
|
|
4. (可选)添加语言切换组件
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## ✅ 已完成的工作
|
|||
|
|
|
|||
|
|
### 后端部分(100% 完成)
|
|||
|
|
|
|||
|
|
#### 1. 核心框架 ✅
|
|||
|
|
- ✅ 创建语言资源文件(messages_zh_CN.properties, messages_zh_TW.properties, messages_en.properties)
|
|||
|
|
- ✅ 配置 MessageSource Bean(MessageSourceConfig.kt)
|
|||
|
|
- ✅ 创建 LocaleInterceptor 拦截器
|
|||
|
|
- ✅ 修改 ErrorCode 枚举,添加 messageKey 字段(100+ 条错误消息)
|
|||
|
|
- ✅ 修改 ApiResponse.error() 方法,支持多语言
|
|||
|
|
- ✅ 创建 MessageUtils 工具类
|
|||
|
|
- ✅ 更新 WebMvcConfig,注册 LocaleInterceptor
|
|||
|
|
|
|||
|
|
#### 2. Controller 更新 ✅(全部完成)
|
|||
|
|
- ✅ AccountController - 完全更新
|
|||
|
|
- ✅ AuthController - 完全更新
|
|||
|
|
- ✅ LeaderController - 完全更新
|
|||
|
|
- ✅ UserController - 完全更新
|
|||
|
|
- ✅ CopyTradingController - 完全更新
|
|||
|
|
- ✅ CopyTradingTemplateController - 完全更新
|
|||
|
|
- ✅ MarketController - 完全更新
|
|||
|
|
- ✅ CopyTradingStatisticsController - 完全更新(包含 CopyOrderTrackingController)
|
|||
|
|
- ✅ ProxyConfigController - 完全更新
|
|||
|
|
- ✅ HealthController - 无需更新(无错误响应)
|
|||
|
|
|
|||
|
|
#### 3. 编译状态 ✅
|
|||
|
|
- ✅ 后端编译通过,无错误
|
|||
|
|
- ✅ 所有 ApiResponse.error() 调用都已传入 messageSource 参数
|
|||
|
|
|
|||
|
|
### 前端部分(部分完成)
|
|||
|
|
|
|||
|
|
#### 1. 核心框架 ✅
|
|||
|
|
- ✅ 安装 i18next 和 react-i18next 依赖
|
|||
|
|
- ✅ 配置 i18n(语言检测、资源加载)
|
|||
|
|
- ✅ 创建语言包文件结构(zh-CN, zh-TW, en)
|
|||
|
|
- ✅ 在 api.ts 中添加语言 Header(X-Language)
|
|||
|
|
- ✅ 在 main.tsx 中初始化 i18n
|
|||
|
|
|
|||
|
|
#### 2. 页面更新 ✅(2个页面已完成)
|
|||
|
|
- ✅ AccountDetail.tsx - 完全使用 i18n
|
|||
|
|
- ✅ App.tsx - 订单推送通知已使用 i18n,Ant Design locale 已配置
|
|||
|
|
- ✅ Login.tsx - 完全使用 i18n
|
|||
|
|
|
|||
|
|
#### 3. 语言包扩展 ✅
|
|||
|
|
- ✅ 添加了登录相关翻译(login.*)
|
|||
|
|
- ✅ 添加了订单相关翻译(order.*)
|
|||
|
|
- ✅ 添加了账户相关翻译(account.*)
|
|||
|
|
- ✅ 添加了通用翻译(common.*)
|
|||
|
|
|
|||
|
|
#### 4. 编译状态 ✅
|
|||
|
|
- ✅ 前端编译通过,无错误
|
|||
|
|
- ⚠️ 有 5 个 TypeScript linter 警告(文件存在,可能是缓存问题)
|
|||
|
|
|
|||
|
|
## ⏳ 待完成的工作
|
|||
|
|
|
|||
|
|
### 前端部分(21个页面待更新)
|
|||
|
|
|
|||
|
|
需要更新以下页面组件,使用 `useTranslation` Hook 替换硬编码文本:
|
|||
|
|
|
|||
|
|
1. AccountList.tsx
|
|||
|
|
2. AccountImport.tsx
|
|||
|
|
3. AccountEdit.tsx
|
|||
|
|
4. LeaderList.tsx
|
|||
|
|
5. LeaderAdd.tsx
|
|||
|
|
6. LeaderEdit.tsx
|
|||
|
|
7. TemplateList.tsx
|
|||
|
|
8. TemplateAdd.tsx
|
|||
|
|
9. TemplateEdit.tsx
|
|||
|
|
10. CopyTradingList.tsx
|
|||
|
|
11. CopyTradingAdd.tsx
|
|||
|
|
12. CopyTradingStatistics.tsx
|
|||
|
|
13. CopyTradingBuyOrders.tsx
|
|||
|
|
14. CopyTradingSellOrders.tsx
|
|||
|
|
15. CopyTradingMatchedOrders.tsx
|
|||
|
|
16. PositionList.tsx
|
|||
|
|
17. OrderList.tsx
|
|||
|
|
18. Statistics.tsx
|
|||
|
|
19. UserList.tsx
|
|||
|
|
20. ResetPassword.tsx
|
|||
|
|
21. SystemSettings.tsx
|
|||
|
|
22. ConfigPage.tsx
|
|||
|
|
|
|||
|
|
### 语言包扩展
|
|||
|
|
|
|||
|
|
根据页面内容,可能需要添加更多翻译键:
|
|||
|
|
- Leader 相关翻译
|
|||
|
|
- Template 相关翻译
|
|||
|
|
- CopyTrading 相关翻译
|
|||
|
|
- Position 相关翻译
|
|||
|
|
- Statistics 相关翻译
|
|||
|
|
- 等等
|
|||
|
|
|
|||
|
|
## 测试建议
|
|||
|
|
|
|||
|
|
### 后端测试
|
|||
|
|
1. ✅ 编译通过
|
|||
|
|
2. ⏳ 测试不同语言 Header 下的错误消息显示
|
|||
|
|
3. ⏳ 测试默认语言(无 Header 时)
|
|||
|
|
|
|||
|
|
### 前端测试
|
|||
|
|
1. ✅ 编译通过
|
|||
|
|
2. ⏳ 测试系统语言自动检测
|
|||
|
|
3. ⏳ 测试语言切换(如果添加了切换功能)
|
|||
|
|
4. ⏳ 测试不同语言下的页面显示
|
|||
|
|
5. ⏳ 测试 API 请求是否正确传递语言 Header
|
|||
|
|
|
|||
|
|
## 使用说明
|
|||
|
|
|
|||
|
|
### 后端
|
|||
|
|
所有 Controller 已更新,错误消息会自动根据 HTTP Header `X-Language` 或 `Accept-Language` 返回对应语言。
|
|||
|
|
|
|||
|
|
### 前端
|
|||
|
|
已更新的页面会自动根据系统语言显示对应文本。其他页面需要逐步更新。
|
|||
|
|
|
|||
|
|
## 下一步
|
|||
|
|
|
|||
|
|
1. 逐步更新剩余的前端页面组件
|
|||
|
|
2. 根据页面内容扩展语言包
|
|||
|
|
3. 全面测试多语言功能
|
|||
|
|
4. (可选)添加语言切换组件
|
|||
|
|
|