Skip to content

fix(i18n): explain the per-job budget stop in the console's language (#409) - #736

Merged
HugoXK merged 1 commit into
mainfrom
dev3/409-budget-stop-bilingual
Nov 15, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev3/409-budget-stop-bilingual

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 15, 2026

Copy link
Copy Markdown
Owner

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.ts in Chinese — one sentence into jobs.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: localizeMessage had 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 — one localizeMessage arm for the stop's reason. It keeps the JOB_BUDGET_PAUSED: / JOB_BUDGET_CANCELLED: prefix so budgetStop, 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 — one ZH_TO_EN row for the notification sentence, matching the second sentence the same function writes. The dashboard reads notifications through localizeNotification, so a localizeMessage arm alone could not fix that half.
  • src/views/pages.ts — budgetStop now localises job.error before stripping the code prefix. Nothing else on the page changes; the Chinese render still shows exactly the sentence the service wrote.
  • Tests: both service-level cases (test/jobBudgetAction.test.ts pause and cancel) assert the stored reason localises to English with no CJK; test/notificationsLocale.test.ts renders the stored JOB_BUDGET_PAUSED notification on an English dashboard and pins the new template row with samples for pause and cancel; test/jobFailureLocale.test.ts renders jobPage in en and zh, extracts the budget banner by its own action target (the page can carry another state-error card), 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 (live main, 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 check exit 0 with 1805/1805 (lint, typecheck, all suites and build).

checkBody → [] against .github/agent/review-policy.json at b0adcc5f; 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.ts at b0adcc5f — 19/24, the five reds above
  • the same three files at this tip — 24/24
  • npm run check at this tip — exit 0, 1805/1805
  • node scripts/changelog.mjs check — 8 fragment(s) ok
  • node scripts/version.mjs check — 0.3.6 ok
  • node scripts/risk-gate.mjs --base b0adcc5f --head HEAD — risk-tier: T2; basis: src/i18n.ts

Not run:

  • The email half of the stop: job mail is Chinese by design (a non-goal in the issue) and nothing here changes it.
  • A browser pass on a real budget stop: the two sentences are asserted at the service boundary and at both render paths, so the strings are pinned where they are produced, not only where they are read.
  • The live instance: production predates the stop (#397), so this is a source-level fix until the next instance update.

Docs-not-needed: docs/architecture.md:1522 already describes the mechanism this change uses — localizeNotification rebuilds 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.md

Risk: risk-tier: T2; basis: src/i18n.ts (label risk:T2)

Tip SHA: 11cc0a6
Tree: 377e03fb2f55c2a9d4c80dec7d03825ff09fde65
Base: 970fc32 (live main after #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 commit b0adcc5f Dev-3 cut from to the live main 970fc32d that had moved by one merge (#724, which touches src/app.ts, docs/* and changelog.d/610.fixed.md and shares no file with this change). The diff is unchanged at 6 files, +93/−1.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. vs Start the job again once the budget is raised.), matching the two Chinese branches written at src/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.ts localises first and strips ^JOB_BUDGET_(PAUSED|CANCELLED): afterwards (src/views/pages.ts:2700-2706), and the localiser returns JOB_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: localizeMessage returns the message verbatim when locale === 'zh' (src/i18n.ts:225), and the test asserts zh.body still carries 12.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.

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 15, 2026
@HugoXK
HugoXK merged commit 0a6dffb into main Nov 15, 2026
35 of 36 checks passed
@HugoXK
HugoXK deleted the dev3/409-budget-stop-bilingual branch November 15, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: the per-job budget stop explains itself in Chinese in the English console

2 participants