Repository navigation
fix(i18n): explain the per-job budget stop in the console's language (#409) - #736
Conversation
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 11cc0a6
Written-by: HugoXK-bot
Author: Fledge Platform Reviewer
Posted-by: HugoXK-bot
T2 i18n change (#409): the per-job budget stop is localised, both in the job page banner and in the dashboard notification, without losing the reason the job stopped.
Reviewed at the tip: src/i18n.ts (+12), src/views/pages.ts (+4/−1), test/jobFailureLocale.test.ts (+43), test/notificationsLocale.test.ts (+25), test/jobBudgetAction.test.ts (+7), changelog. 6 files, +93/−1.
What I checked, including the two places a bilingual fix usually leaks:
- pause and cancel are not one template. The reason arm captures
(PAUSED|CANCELLED)and chooses a different English action sentence (Resume from the checkpoint once the budget is raised, or start the job again.vsStart the job again once the budget is raised.), matching the two Chinese branches written atsrc/jobs/service.ts:2412-2414(提高单任务预算后从断点恢复,或重新开始任务。vs...后重新开始任务。). The notification arm has its own, separately-worded regex (src/i18n.ts:314-316) because that sentence is different again ("因单任务预算取消/暂停:已用 … 元,预算 … 元"). - the prefix survives.
pages.tslocalises first and strips^JOB_BUDGET_(PAUSED|CANCELLED):afterwards (src/views/pages.ts:2700-2706), and the localiser returnsJOB_BUDGET_<code>: …(src/i18n.ts:265-269), so the banner keeps its body; stripping before localising, as the old one-liner did, would have left the Chinese sentence for an English reader. - Chinese readers get the backend sentence unchanged:
localizeMessagereturns the message verbatim whenlocale === 'zh'(src/i18n.ts:225), and the test assertszh.bodystill carries12.50 元. - the technical-details copy is the untouched raw reason, which the test also pins — operator text is not translated.
Ran (this turn, at this tip):
npx tsx --test test/jobFailureLocale.test.ts test/notificationsLocale.test.ts test/jobBudgetAction.test.ts— pass 24/24
Red half (same suites at b0adcc5f): 19 pass / 5 fail, including not ok 16 - a per-job budget stop renders the job page banner in the reader's language and not ok 17.
Not run: a real mail client; the notification test renders the dashboard.
Conclusion: PASS — pause and cancel keep distinct advice, the code prefix is preserved for the banner consumer, and the Chinese render is unchanged.
Written-by: HugoXK
Author: Fledge Platform Dev-3
Fixes #409
maintainer_can_modify: false (same-repo head, GitHub-forced)
What was wrong
The per-job budget stop is written by
src/jobs/service.tsin Chinese — one sentence intojobs.error(JOB_BUDGET_PAUSED: 单任务成本 … 元已超过预算 … 元。…) and a different sentence into the notification (任务 … 因单任务预算暂停:已用 … 元,预算 … 元。…). The console localises the title (Per-job budget reached) but passed both sentences through verbatim:localizeMessagehad no arm for the reason, and the English notification table had one budget row, for the older after-the-spend alert, so an English console showed a Chinese paragraph under an English heading and an English notification list with one Chinese row.What changed
src/i18n.ts— onelocalizeMessagearm for the stop's reason. It keeps theJOB_BUDGET_PAUSED:/JOB_BUDGET_CANCELLED:prefix sobudgetStop, which strips that prefix for the banner body, keeps working unchanged; cost and budget stay data. The pause and cancel sentences differ in their advice, so each gets its own English form.src/i18n.ts— oneZH_TO_ENrow for the notification sentence, matching the second sentence the same function writes. The dashboard reads notifications throughlocalizeNotification, so alocalizeMessagearm alone could not fix that half.src/views/pages.ts—budgetStopnow localisesjob.errorbefore stripping the code prefix. Nothing else on the page changes; the Chinese render still shows exactly the sentence the service wrote.test/jobBudgetAction.test.tspause and cancel) assert the stored reason localises to English with no CJK;test/notificationsLocale.test.tsrenders the storedJOB_BUDGET_PAUSEDnotification on an English dashboard and pins the new template row with samples for pause and cancel;test/jobFailureLocale.test.tsrendersjobPageinenandzh, extracts the budget banner by its own action target (the page can carry anotherstate-errorcard), and checks the technical-details block still shows the operator's raw sentence.changelog.d/409-budget-stop-english.fixed.md— the user-visible half.Evidence
Red at
b0adcc5f7380672a4c5afe1538bb57675017cdf7(livemain, unmodified sources plus these tests): 19 pass / 5 fail.the English reason must not be the raw Chinese sentence: JOB_BUDGET_PAUSED: 单任务成本 7.20 元已超过预算 0.01 元。…the English banner leaked the backend sentence: 单任务成本 12.50 元已超过预算 10.00 元。…the English budget notice must not contain CJK: 任务 job_8 因单任务预算暂停:已用 12.50 元,预算 10.00 元。…Green at this tip: the same three files 24/24, and
npm run checkexit 0 with 1805/1805 (lint, typecheck, all suites and build).checkBody→[]against.github/agent/review-policy.jsonatb0adcc5f; 6 files changed, +93/−1, no size-rule line needed.Ran:
npx tsx --test test/jobBudgetAction.test.ts test/notificationsLocale.test.ts test/jobFailureLocale.test.tsatb0adcc5f— 19/24, the five reds abovenpm run checkat this tip — exit 0, 1805/1805node scripts/changelog.mjs check— 8 fragment(s) oknode scripts/version.mjs check— 0.3.6 oknode scripts/risk-gate.mjs --base b0adcc5f --head HEAD—risk-tier: T2; basis: src/i18n.tsNot run:
#397), so this is a source-level fix until the next instance update.Docs-not-needed:
docs/architecture.md:1522already describes the mechanism this change uses —localizeNotificationrebuilds a stored sentence from the template it matches, both directions — and it does not enumerate the sentence inventory, so there is no documented claim to update.Changelog:
changelog.d/409-budget-stop-english.fixed.mdRisk:
risk-tier: T2; basis: src/i18n.ts(labelrisk:T2)Tip SHA: 11cc0a6
Tree: 377e03fb2f55c2a9d4c80dec7d03825ff09fde65
Base: 970fc32 (live
mainafter #724 merged)Diff: 6 files, +93/−1
How this branch was pushed
Dev-3's seat has no push credential (Chief's decision: the shared token stays off extra seats). The commit was built and tested locally by Dev-3 with
Day Dreamer <87640074+HugoXK@users.noreply.github.com>as author and committer, then pushed by the Lead through the API Git Data path: same tree, same author, parent re-pointed from the commitb0adcc5fDev-3 cut from to the livemain970fc32dthat had moved by one merge (#724, which touchessrc/app.ts,docs/*andchangelog.d/610.fixed.mdand shares no file with this change). The diff is unchanged at 6 files, +93/−1.