Repository navigation
fix(ui): translate the remaining user-visible backend errors in English mode - #165
Merged
Merged
Conversation
…sh mode ERR_MAP maps the backend's Chinese error strings to English translation keys. Several messages returned on paths a user can actually reach were never wired into it, so English-mode users saw raw Chinese. The clearest case was an orphaned key: err.network was defined in both packs and its Chinese value is exactly the literal api.js passes to mapErr on a network failure, but no ERR_MAP entry referenced it - the translation existed and was unreachable. Covered now (all on paths the console calls): err.network 网络不可用,请检查后端服务是否启动 (api.js network failure) err.emailNotRegistered 该邮箱未注册 (auth/reset_password, forgot-password form) err.raisePending 已有待审批的加额申请,请等待管理员处理 (raise_requests/create) err.raiseHandled 该申请已处理 (raise_requests approve/reject) err.codeSendFail 验证码发送失败,请重试 (auth/login 502) err.modelExists 模型已存在(provider+model 唯一) (admin/models create/patch) err.negativePrice 价格不能为负数 (admin/models create/patch) Six new keys were added to both packs (769 -> 775, ZH == EN); err.network already existed and only needed wiring. Coverage of the 40 production backend error strings goes from 18 to 24. Verified against the true pre-fix baseline (git HEAD), replaying every real message through the real mapErr in EN mode: exactly 7 messages change, all from raw Chinese to English, and 0 regressions - the single merged entry that covers two sources (err.network) is counted once. Controls: zh passthrough, unmatched passthrough, null passthrough, and a wired key still translating. Deliberately NOT covered, to keep this change honest rather than exhaustive: the remaining unmapped strings are defensive validation on URLs/states the console never generates (wallet "type must be..." / ISO-8601 params, sharing "status must be...", admin-models field validators, org field validators, gateway body validators), plus one literal for an expired session that is never displayed. They fail closed as raw Chinese.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ERR_MAPinui/js/i18n.jsmaps the backend's Chinese error strings to English translation keys. Several messages returned on paths a user can actually reach were never wired into it, so English-mode users saw raw Chinese.The clearest case is an orphaned key:
err.networkis defined in both packs, and its Chinese value is exactly the literalapi.jspasses tomapErron a network failure (ui/js/api.js:66) — but noERR_MAPentry referenced it. The translation existed and was unreachable:Covered in this PR, each on a path the console actually calls:
err.network(key already existed)api.js:66network failureerr.emailNotRegisteredauth/reset_password(src/routes/mod.rs:388) — forgot-password formerr.raisePendingraise_requests/createerr.raiseHandledraise_requestsapprove/rejecterr.codeSendFailauth/login502err.modelExistsadmin/modelscreate/patcherr.negativePriceadmin/modelscreate/patchSix new keys were added to both packs (769 → 775,
ZH == EN);err.networkalready existed and only needed wiring. Coverage of the 40 production backend error strings goes from 18 → 24.Related Issue
Changes
ui/js/i18n.js— six newerr.*keys in both packs; seven newERR_MAPentries (kept longest-first, per the ordering convention established in fix(ui): resolve backend error messages by longest match instead of first match #164).ui/index.html— cache-bust?v=20260911-9→-10(5 references).Tests
cargo test— 148 passed; 0 failedcargo fmt --check— cleancargo clippy --all-targets -- -D warnings— cleannode --checkon all fourui/js/*.js— cleanBehavioural verification (no JS test runner exists in this repo — its convention is Rust
#[cfg(test)]and CI runs fmt/clippy/test only, so none was added):git show HEAD:ui/js/i18n.js, replaying every real message through the realmapErrin EN mode: exactly 7 messages change, all from raw Chinese to English, 0 regressions. (err.networkis a single merged entry covering two sources, so it counts once — hence 7 changed vs 7 cases listed above.)nullpassthrough ✅, and a previously-wired key still translating ✅.点数余额不足,该邮箱已注册,模型不存在,验证码错误).Checklist
fix/<description>)fix(ui): …)Deliberately NOT covered
To keep this honest rather than exhaustive, the remaining unmapped strings are defensive validation on URLs/states the console never generates — wallet
type 必须为…/ ISO-8601 params, sharingstatus 必须为…, admin-models field validators, org field validators, gateway body validators — plus one expired-session literal that is never displayed (__atpLogoutshows a different message). They fail closed as raw Chinese. Happy to cover any of them if you'd rather have full coverage.