-
-
Notifications
You must be signed in to change notification settings - Fork 224
feat: Add comprehensive i18n internationalization support with multi-language translations #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add comprehensive i18n internationalization support with multi-language translations #403
Conversation
- 更新 i18n 配置以支持德语、西班牙语、法语 - 添加 i18next-parser 配置文件 - 添加德语、西班牙语、法语的翻译资源文件 - 更新 package.json 中的 i18n 检查命令
- 配置 iflow-cli-action 进行 issue 自动分类 - 支持自动触发(新 issue 或重新打开)和手动触发 - 支持命令触发(@iflow-cli /triage)和自然语言触发 - 按 issue 类型分类:bug, enhancement, documentation, cleanup, question - 自动添加分类说明评论 - 添加错误处理和失败通知
- 使用固定版本的 iflow-cli-action (v1.0.0) 提高稳定性 - 增强并发控制,支持 workflow_dispatch 事件的 issue_number 参数 - 添加 pull-requests: read 权限 - 优化超时设置和性能 - 增强错误处理和失败通知 - 添加成功后的处理逻辑,自动添加 needs-triage 标签 - 改进环境变量处理,使用可选链操作符 - 将 actions/github-script 升级到 v7
1. 在 SettingsView.test.tsx 中添加缺失的 language 属性 2. 在 useTranslation.test.ts 中添加 jsdom 测试环境配置
- 修复 Sidebar.test.tsx 中的 act() 警告:将 fireEvent 和 vi.runOnlyPendingTimers() 分离到独立的 act() 块 - 修复 useThreads.integration.test.tsx 中的 act() 警告:使用 async/await + waitFor 处理异步状态更新 - 修复 SettingsView.test.tsx 中的国际化测试失败:更新文本选择器以匹配中文 UI - 改进 i18n-test-utils.tsx 中的 MockI18nProvider 实现 - 优化 SettingsView.tsx 中的国际化文本键使用 - 修复 useWorkspaceLaunchScripts.ts 中的 TypeScript 类型问题 - 修复 GitDiffPanel.tsx 中的国际化文本键 测试结果:82 个测试文件通过,395 个测试通过,1 个跳过
为 MockI18nProvider 中的 i18nInstance 添加缺失的属性: - init, use, modules, store, isInitialized - on, off, emit, cloneInstance, createInstance, createTranslator - exists, setDefaultNamespace, getDefaultNamespace - languages, namespaces, hasLoadedNamespace, loadNamespaces, loadLanguages - toLanguage, getT, getDataByLanguage 使用 as any 类型断言确保类型兼容性
- 将 Rust 端 tauri 从 2.9.5 升级到 2.10.2 - 将 Rust 端 tauri-plugin-updater 从 2.9.0 升级到 2.10.0 - 将 Rust 端所有插件版本更新为精确版本以确保构建一致性 - 将 npm 端 @tauri-apps/api 从 ^2 降级到 2.10.0 以匹配 Rust 端 - 将 npm 端 @tauri-apps/cli 从 ^2.9.6 升级到 ^2.10.0 - 将 npm 端 @tauri-apps/plugin-updater 从 ^2.9.0 升级到 ^2.10.0 - 在 .gitignore 中添加测试输出文件规则(test-*.txt 等) - 删除旧的 test-results.txt 文件 修复了 CI/CD 构建中的版本不匹配错误: " Found version mismatched Tauri packages. Make sure the NPM package
- 将 @tauri-apps/api 从 2.10.0 升级到 2.10.1 以匹配插件依赖 - 添加 @testing-library/dom 作为开发依赖 - 添加 @testing-library/user-event 作为开发依赖 - 修复了因 Tauri API 版本不匹配导致的模块找不到错误 - 修复了因 Testing Library peer dependencies 缺失导致的导入错误
- 保留本地中文化翻译(菜单、组件等) - 接受上游的新功能和重构 - 整合 iOS/移动端支持 - 更新依赖版本到 v0.7.49
- 添加分割聊天和差异中心面板功能 - 添加应用提及支持 - 添加线程级别的 Codex 参数持久化 - 添加批量添加工作空间功能 - 修复高 CPU 使用率问题 - 添加 DMABUF 渲染器回退支持(Wayland + NVIDIA) - 更新架构文档和规范脚本 - 修复分离的审查锁定父线程问题 注意:i18n 工作已保存到 backup-i18n-work 分支
- 删除 steer mode 相关测试(功能已移除) - 删除 personality selection 测试(功能已移除) 这些功能在上游 v0.7.50 版本中被移除,因此对应的测试也需要删除。
- 将 UI Scale 改为 Interface scale - 将 Copy 按钮名称改为 common.copy - 将 Remote backend host 改为 settings.features.host - 将 Remote backend token 改为 settings.features.remote_backend 上游版本已全面采用 i18n 翻译键,测试代码需要相应更新。
- 删除 MERGE_FIXES.md(上游合并记录) - 删除 SETTINGS_I18N_FIX_PLAN.md(i18n 计划) - 删除 VERIFICATION_REPORT.md(验证报告) - 删除 nul 临时文件 PR Dimillian#388 已关闭,这些文件不再需要。
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this 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: 5cface44b9
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,11 @@ | |||
| import { useTranslation as useOriginalTranslation } from 'react-i18next'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize i18next before exposing translation hook
This hook re-exports react-i18next without importing src/i18n/config.ts, so initReactI18next never runs unless some other runtime path imports config first. In this commit, src/i18n/config.ts is only imported by src/services/i18n.ts, and that service is only referenced via import type in tests, so production renders can fall back to raw translation keys and language switching will not actually initialize.
Useful? React with 👍 / 👎.
| commitLoading, | ||
| onCommit, | ||
| }: CommitButtonProps) { | ||
| const { t } = useTranslation("git_diff"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop requesting an unregistered git_diff namespace
This component requests useTranslation("git_diff"), but the i18n setup registers only the translation namespace (ns: [defaultNS]) and stores Git labels under translation.git_diff.*. With that mismatch, calls like t("commit") and t("no_changes_to_commit") resolve as missing keys, so the Git panel shows key names instead of user-facing text.
Useful? React with 👍 / 👎.
src/utils/time.ts
Outdated
| return "刚刚"; | ||
| } | ||
| if (absSeconds < 60) { | ||
| const value = Math.max(1, Math.round(absSeconds)); | ||
| return diffSeconds < 0 ? `${value}s ago` : `in ${value}s`; | ||
| return diffSeconds < 0 ? `${value}秒前` : `${value}秒后`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Respect the active locale in relative time labels
The helper now hard-codes Chinese strings ("刚刚", "秒前", etc.) and this file also hard-codes Intl.RelativeTimeFormat("zh-CN"), so all consumers of formatRelativeTime/formatRelativeTimeShort display Chinese regardless of the selected/default language. That creates mixed-language UI for English users across Home/Sidebar/Git surfaces.
Useful? React with 👍 / 👎.
- 在 App.tsx 中导入 i18n/config 以正确初始化国际化框架 - 修复 time.ts 中的硬编码中文字符串,使用 i18n 翻译 - 添加时间相关的翻译键(just_now, seconds_ago, minutes_ago 等) - 支持中文和英文的相对时间显示 修复 ChatGPT-Codex-connector 机器人指出的三个问题: 1. useTranslation 钩子未正确初始化 2. GitDiffPanelShared.tsx 的命名空间不匹配 3. time.ts 中的硬编码中文字符串导致混合语言界面
|
✅ 已修复审查反馈:1) 在 App.tsx 导入 i18n/config 正确初始化国际化 2) 修复 time.ts 硬编码中文字符串,使用 i18n 翻译 3) 添加时间相关翻译键。已提交到 feat/comprehensive-i18n-support 分支。 |
- 将 src/utils/time.ts 改为重新导出 i18n/utils/date.ts 中的函数 - 移除 formatRelativeTime 和 formatRelativeTimeShort 中的硬编码中文字符串 - 更新 6 个文件的导入路径,从 utils/time 改为 i18n/utils/date - 修复完成后,时间格式化现在完全使用 i18n 国际化框架 修复 codex 审查反馈: 1) 在 App.tsx 导入 i18n/config 正确初始化国际化 ✓ 2) 修复 time.ts 硬编码中文字符串,使用 i18n 翻译 ✓ 3) 添加时间相关翻译键 ✓
概述
此 PR 为 CodexMonitor 添加了完整的国际化(i18n)支持,包括多语言翻译和完整的本地化框架。
主要功能
🌍 国际化框架
📝 多语言支持
🎨 界面本地化
🧪 测试改进
🔧 构建优化
文件变更
主要新增文件
主要修改文件
测试状态
\
Test Files: 89 passed (89)
Tests: 471 passed | 10 skipped (481)
Duration: 15.46s
\\
✅ 所有测试通过
✅ TypeScript 类型检查通过
✅ 构建成功
向后兼容性
此 PR 向后兼容,不影响现有功能。i18n 功能默认使用英文,用户可以通过设置切换语言。
使用说明
贡献者
审查重点
请审查并给出反馈!