Repository navigation
Add i18n support and Simplified Chinese translations - #339
ManuZhu0728 wants to merge 2 commits into
Conversation
Add English and Simplified Chinese resources and a persisted language selector with automatic locale detection. Initialize localization in the lazy-loaded main and create-torrent views, and localize dialogs, torrent details, tables, native menus, notifications, and client-side errors.
qu1ck
left a comment
There was a problem hiding this comment.
Thanks for working on this, looks promising!
I need to do some in-depth testing but a few general comments:
- Move all i18n related ts(x) files into
src/i18n. Locales intosrc/i18n/locales/ - Adding a language involves changing ~20 places across like ~7 files. Can it be simplified? Ideally it should be 1-2 lines in 1-2 files (js and rust each). Use enums where possible, especially in rust. Also add a readme in i18n folder describing how to add a new language support.
- I don't understand the purpose of
createtorrentapp. You dont need to load config there, you already get the language alongside the theme from main window through window messaging mechanism. In fact loading config from file is not reliable as config is not always immediately saved when changed. Don't worry about lazyloading it either, it doesnt matter if it's entrypoint is large because it only appears in app. Also changing the webchunk name breaks my build scripts. - No russian strings? I seem to recall your fork had russian too. It's ok if they are incomplete, I can provide missing russian translations later.
Group i18n helpers and locale resources under src/i18n. Derive language support from one TypeScript registry and one Rust enum declaration, and document how to add a language. Initialize the creation window from the main window message, remove its separate configuration read, and restore the createtorrentform chunk name. Migrate the fork's partial Russian translations with English fallback. Refresh the localized generic window title when no active server tab exists.
|
Thanks for the feedback. I’ve updated the PR to address all four points:
The Linux release build, TypeScript checks, ESLint, and 26 local regression tests pass. I also checked the existing web packaging rules and exercised the actual Linux application under GNOME/XWayland: language switching and persistence, the creation window, native file/directory selection, torrent generation and saving, and tray actions. During these checks, I found and fixed a small i18n issue where the main window title retained the previous language when no server was configured. Windows/macOS and the native Wayland backend remain unverified. |
引入 i18next/react-i18next 架构:src/i18n/{index,language,translate}.ts
+ locales/{en,zh-CN,ru}.json,Rust 端 src-tauri/src/i18n.rs 通过
define_languages! 宏复用同一份 JSON 资源。
上游参考:openscopeproject#339
在 upstream master (v1.5.1) + PR openscopeproject#339 i18n 框架之上回植汉化版独有功能: 过滤面板 (filters.tsx / statusicons.tsx) - 暂停子状态:已暂停下分出「已完成 / 未完成」两级子过滤器 - 错误分布分组:按 cachedError 聚合,含「无错误」汇总行 - 目录分组复制路径:目录行右侧一键复制 - 双击全选分组:右键菜单可开关 工具栏 / 种子列表 (toolbar.tsx / torrenttable.tsx) - 批量开始/暂停:全部、已完成、出错、下载中五类批量操作 - 复制名称 / 复制路径:批量去重后写入剪贴板 - tr3 批量改 Tracker:解除 transmission 4.0 以下的多选限制 运行状态与删除 (server.tsx / status.ts / remove.tsx) - 运行状态面板:新建 src/status.ts,右下角常驻显示运行操作与选中项 - 单选也删数据:仅选中一个种子时也可删数据,自动避开共享路径 添加种子 (add.tsx / servermodals.tsx / client.ts) - 拖拽批量添加:整批交给单个弹窗逐个处理 - 磁力链接下载间隔:可设间隔秒数 - Web 版 URL 凭据重定向:修复同源连接时的跨域问题 配套 - config.ts 新增配置项与旧中文分组名迁移 - en.json / zh-CN.json 词表对齐至 600 key - ci/build_web_zh.sh:Web 产物打包脚本 - README.md 重写为汉化版说明
This adds internationalization to the desktop and web interfaces, with English, Simplified Chinese, partial Russian translations, English fallback, and automatic language detection.
src/i18n/. Adding a language requires its JSON resource and one registration entry each in TypeScript and Rust;src/i18n/README.mddocuments the process. Rust stores the selected language as an enum.createtorrentformchunk name is preserved. Resources use i18next JSON v4 plural forms.Chinese wording and the partial Russian translations follow the existing translations in my fork. Existing option values, RPC operations, user-provided text and daemon diagnostics are preserved.
Validation for
87f58f0:npm run build -- --no-bundlepassed locally.Validation coverage was limited to Linux under XWayland and one web browser. Web language preferences were emulated, and test torrents were added paused. Windows/macOS UI, native Wayland clients, other browser engines, successful transfers, completion notifications and daemon persistence remain unverified. The Web checks do not establish pixel-level layout or piece-canvas rendering. Russian translations remain partial and have not had native-speaker proofreading.
Already-open torrent-creation windows retain their language until reopened. Native file-picker controls follow the system locale.
AI assistance
This contribution was developed using OpenAI Codex with the GPT-6.1 Sol model throughout the process, including implementation, translation drafting, code review, execution of build and regression checks, and preparation of this PR description. Chinese wording was checked against the existing translations in my fork. The validation scope and remaining limitations are documented above.