feat(i18n): add English and Simplified Chinese localization - #168
squarepots wants to merge 111 commits into
Conversation
fix(web): isolate slow requests with bounded workers
…on' into work/i18n-final # Conflicts: # src-tauri/src/auth/storage.rs # src-tauri/src/commands/account.rs # src-tauri/src/commands/usage.rs
|
@Lampese 这批 #165–#175 我已经完成最后一轮 review 和集成收口。当前所有 PR 都是 Open、非 Draft,GitHub 均显示 mergeable,也没有 unresolved review thread。 这轮重点重新检查了 #168。它之前的集成验证基于较早的 dependency heads,而 #166、#167、#171、#172、#173 后续又有修改。按最终实现重新核对后,我在 #168 中发现并修复了三个会重新引入旧问题的地方:
同时,#168 的 runtime auth reconciliation 已对齐 #171 的最终行为,并补回相关 regression coverage。当前 #168 head 是 重新核对后,#168 现在保留了这批依赖中的关键行为:
建议按依赖关系处理:
目前剩下的验证项是 CI。#175 的 workflow 已被 GitHub 识别,但 fork PR run 仍停在 @Lampese I finished the final review and integration pass for #165–#175. All of the PRs are currently open, non-draft, reported as mergeable by GitHub, and have no unresolved review threads. The main integration work in this pass was #168. Its earlier validation was based on older dependency heads, while #166, #167, #171, #172, and #173 changed afterward. Rechecking #168 against their final behavior found three regressions that would otherwise have been reintroduced:
Those are now fixed. #168 also uses the final runtime-auth reconciliation behavior from #171 and includes the relevant regression coverage. The current #168 head is I rechecked the integration boundaries after these changes. #168 now preserves the relevant behavior from:
Suggested dependency order:
The remaining verification step is CI. GitHub recognizes the workflow added by #175, but the fork PR run is still stopped at |
中文
实现状态
本 PR 完成 Codex Switcher 的双语本地化基础,并继续使用现有的 #168 分支与 PR。
AppSettings.ui_language_preference作为唯一持久化 authority,支持System default、English、简体中文;解析后的en-US/zh-CN同步到主窗口、托盘 webview、原生应用菜单和原生托盘菜单。Browser default、English、简体中文。当前 JS session 的 in-memory preference 是唯一 semantic authority;localStorage 只做尽力持久化。显式选择先更新内存,即使 storage 不可用,React、设置 picker 和 web-secret prompt 也保持一致;Browser default才按navigator.languages的第一个受支持语言解析,且不会写入桌面设置。initialize_app_settings()决定:新安装持久化 System,已有 pre-localization 安装及缺少语言字段的 legacy settings 持久化 English,显式偏好和 legacylanguage字段保持不变。普通 runtime read 只读取AppSettings;缺失 settings 时固定使用 English safe fallback,绝不再依据accounts.json重新推断语言。设置写入继续复用 locked/atomic persistence。zh-CN、zh_CN、zh-Hans、zh-Hans-*、zh-SG,并让zh-TW、zh-HK、zh-MO、zh-Hant*、裸zh回退到 English。DisplaySettings,先尽力投影 native menu/tray,再通过现有app-settings-changed机制通知 webview;投影失败不会伪报持久化失败。document.documentElement.lang仅是已解析语言的 projection,不是 browser authority。2b85209e)、feat(backup): add user-passphrase encryption #170(30a6d18c)、fix(auth): make activation a single transaction #171(ad31b476)、fix(auth): align OAuth refresh policy with Codex #172(26ab3448)和 feat(warmup): persist host-owned scheduling policy #173(fa97f003)验证,保留 web boundary、passphrase backup、auth transaction、OAuth refresh 和 Rust-owned warm-up scheduler 的既有行为。验证
pnpm test:i18n:8 项通过pnpm test:desktop-reopen:7 项通过pnpm test:close-preference:3 项通过pnpm test:reset-credits:3 项通过pnpm test:warmup-policy:1 项通过pnpm test:web-boundary:1 项通过pnpm test:backup-passphrase:3 项通过pnpm build:通过cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check:通过cargo check --locked --manifest-path src-tauri/Cargo.toml:通过cargo test --locked --manifest-path src-tauri/Cargo.toml:92 项通过git diff --check:通过Closes #157
English
Implementation status
This PR completes the bilingual localization foundation for Codex Switcher while continuing the existing #168 branch and pull request.
AppSettings.ui_language_preference, withSystem default,English, and简体中文. The resolveden-US/zh-CNlanguage is projected to the main window, tray webview, native application menu, and native tray menu.Browser default,English, and简体中文. The current JS session in-memory preference is the single semantic authority; localStorage is best-effort persistence only. Explicit choices update memory first, so React, the settings picker, and the web-secret prompt stay aligned even when storage is unavailable. OnlyBrowser defaultresolves the first supported entry fromnavigator.languages, and it never writes desktop settings.initialize_app_settings(): new installs persist System; existing pre-localization installs and legacy settings without language persist English; explicit preferences and the legacylanguagefield survive. Ordinary runtime reads only readAppSettings; a missing settings file always uses the English safe fallback and never re-infers language fromaccounts.json. Settings writes reuse locked/atomic persistence.zh-CN,zh_CN,zh-Hans,zh-Hans-*, andzh-SG;zh-TW,zh-HK,zh-MO,zh-Hant*, and barezhfall back to English.DisplaySettings, attempt native menu/tray projection before notifying webviews through the existingapp-settings-changedmechanism, and do not report persistence failure when a projection fails.document.documentElement.langis only a projection of the resolved language, never browser authority.2b85209e), feat(backup): add user-passphrase encryption #170 (30a6d18c), fix(auth): make activation a single transaction #171 (ad31b476), fix(auth): align OAuth refresh policy with Codex #172 (26ab3448), and feat(warmup): persist host-owned scheduling policy #173 (fa97f003), preserving the existing web boundary, passphrase backup, auth transaction, OAuth refresh, and Rust-owned warm-up scheduler behavior.Validation
pnpm test:i18n: 8 passedpnpm test:desktop-reopen: 7 passedpnpm test:close-preference: 3 passedpnpm test:reset-credits: 3 passedpnpm test:warmup-policy: 1 passedpnpm test:web-boundary: 1 passedpnpm test:backup-passphrase: 3 passedpnpm build: passedcargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check: passedcargo check --locked --manifest-path src-tauri/Cargo.toml: passedcargo test --locked --manifest-path src-tauri/Cargo.toml: 92 passedgit diff --check: passedCloses #157