Skip to content

fix(l10n): localize loader failed-state titles in both apps - #859

Merged
wei18 merged 1 commit into
mainfrom
fix/854-loader-l10n
Jul 17, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/854-loader-l10n

Conversation

@wei18

@wei18 wei18 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

What

Closes #854 — loader .failed titles rendered untranslated English. Adds "Couldn't load saved game." (MS catalog, both MS loaders) and "Couldn't load puzzle." (Sudoku catalog — the issue's literal instruction named the MS string for both apps, but Sudoku's BoardLoaderView actually renders different copy; following the source, not the issue text, and disclosed) ×7 locales. Close/Retry + error-body keys verified pre-existing. Catalog-only diff (+144), fixture regenerated.

Review

Dual review (>50 LOC rule): mechanical checks folded into the adversarial pass — APPROVE: byte-identical key↔source match on all 3 call sites (Text("literal") localizes; no verbatim/interpolation), translation terminology cross-checked against neighboring entries (es 'puzle' consistent across 8 existing keys), pure-additive splice (0 deletions), per-app placement per convention. Scanner source-literal blindspot stays open as noted in the commit.

Verification

scan:l10n green ×2 · SudokuKit Board 65/65 · MinesweeperKit 335/335 --no-parallel · gitleaks clean.

🤖 Generated with Claude Code

MinesweeperBoardLoaderView and MinesweeperDailyReplayLoaderView both
render "Couldn't load saved game." in their .failed block, but the key
was absent from Minesweeper's Localizable.xcstrings — non-English
users saw English. Added the key ×7 locales to
App/Minesweeper/Resources/Localizable.xcstrings.

Auditing Sudoku's BoardLoaderView (the mirrored surface) turned up the
same gap with different copy: "Couldn't load puzzle." was also missing
from Sudoku's catalog. Added the key ×7 locales to
App/Sudoku/Resources/Localizable.xcstrings. Close/Retry button labels
in all three loader failed-state views were already catalog keys in
both apps — no gap there.

Both strings are per-app (different literal text, not shared copy),
so each key lives only in its own app's catalog, following the
existing convention (e.g. "Couldn't load leaderboard." is duplicated
across apps only because the literal text is identical in both).
Regenerated the SudokuAppCompositionTests fixture via
gen:l10n_fixture to keep it byte-synced.

The scanner's source-literal blindspot (scan:l10n validates catalog
completeness, not source-string coverage — this exact gap type would
recur silently) remains an open follow-up per the issue's "bigger
question"; not addressed here.

Closes #854

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 17, 2026 08:23
@wei18
wei18 merged commit c3697ec into main Jul 17, 2026
5 checks passed
@wei18
wei18 deleted the fix/854-loader-l10n branch July 17, 2026 08:23
wei18 added a commit that referenced this pull request Jul 17, 2026
…oku (#868)

Sudoku's board toolbar always showed "Pause" (bars icon), even before any
digit was placed, even though tapping it only ever opened the "Leave Game?"
sheet — no real pause feature exists yet. Minesweeper's equivalent control
was already state-aware: "Leave" + X pre-first-reveal, "Pause" + bars once
playing. Per #849 adjudication, extract the shared state→label/icon mapping
into `BoardLeaveOrPauseState` / `BoardLeaveOrPauseButton` (GameShellUI, zero
deps) and have both board views derive their own Ready-state signal from it.

Sudoku has no `.idle` board render (`startOrResume()` fires during
`BoardLoaderView`, before the toolbar ever mounts), so its semantically
equivalent Ready signal is "no move made yet on a live session" —
`status == .playing && !canUndo` (`canUndo` mirrors the session's undo
stack, which only digit placement/erase populates, never pencil notes).
Both apps gained a small view-local `showReadyLeaveOverlay` /
`showIdleLeaveOverlay` flag so tapping Leave-ready opens the shared
"Leave Game?" sheet without an illegal pause transition; Resume just hides
the flag. Sheet behavior itself is unchanged.

No new localized strings: `leave.game.leave`, `Pause`, `Resume` already
carry all 7 locales in both catalogs.

Snapshot churn (17 baselines, all reviewed as legitimate):
- 7 fresh/no-move-yet boards now show Leave+X instead of Pause+bars (the
  intended #849 fix): BoardViewBannerTests ads-enabled iPhone light/dark,
  BoardViewTests empty iPhone light/dark-ja/Mac light/dark,
  BoardViewPencilNotesTests (notes-only boards have no digit-undo history).
- 10 fixtures with placed digits (InProgress ×5, AlmostComplete ×4,
  ArmedDigit ×1) needed their `canUndo` fixture value corrected to match
  their visible board content (previously always false regardless of
  placed digits) — toolbar itself is pixel-identical (stays Pause), the
  Undo/Redo buttons flip from incorrectly-disabled to correctly-enabled.

Rebased onto ecea204 (#859/#860/#862): #860's DigitPadView contrast/a11y
rewrite re-recorded 8 of the same iPhone-compact baselines this change
touches. Took upstream as the merge base for the 8 PNG conflicts, then
re-recorded on the fully rebased tree so each baseline reflects the union
of both changes (verified pixel-diffed, e.g. the empty-board banner fixture
now shows both this fix's Leave/X toolbar and #860's digit-pad ink fix in
one frame). No source conflicts — #862's `BoardView+Completion.swift` /
`BoardLoaderView.swift` changes didn't touch the lines this PR edits.

CR round 2 (3 findings, all addressed):

Finding 1 (clock-model honesty): the original comment claimed straight MS
parity, but Sudoku's clock starts at `GameSession.start()` — called by
`BoardLoaderView` before the toolbar ever mounts — while MS's clock starts
only on first reveal/flag. Empirically verified (`GameSessionElapsedTests
.startAtZero`, SudokuCoreKit, plus a new live-session test here) that
`elapsedSeconds == 0` IS the real state at the instant `startOrResume()`
returns, so the Ready window is reachable — just far narrower than MS's:
gated `.leaveReady` on `elapsedSeconds == 0 && !canUndo` (was `!canUndo`
alone), and rewrote the code comment to state the clock-model asymmetry
plainly instead of claiming parity. This also fixes the real bug the
finding flagged: a pencil-marking player (`toggleNote` never touches
`undoStack`) or anyone who's simply let a second tick by now correctly
sees Pause, not Leave, once the clock has genuinely started accruing time.
Verified pause-overlay shape parity separately: both apps mount the exact
same shared `PauseOverlayView` with identical default strings
(`leave.game.title` "Leave Game?" / `leave.game.leave` "Leave") for a
genuine pause AND the Ready-state Leave-confirm — this is pre-existing,
shared, cross-app behavior, not something #849 introduced, so no shape
change was needed.

Finding 2 (resume-mount race): `BoardLoaderView.mountLoaded` renders
`BoardView` (`state = .loaded(viewModel)`) before `await
viewModel.startOrResume()`'s resync lands, so a resumed mid-game
`GameViewModel` could momentarily read the constructor's default
`canUndo == false` and flash `.leaveReady` for one frame. Added
`initialCanUndo` to the live `GameViewModel` init and threaded
`!snapshot.undoMoves.isEmpty` through at construction in
`BoardLoaderView.mountLoaded` — no transient wrong label.

Finding 3 (fixture fidelity): `BoardViewTests.makeViewModel`'s `canUndo`
derivation (`!userCells.isEmpty || elapsedSeconds > 0`) couldn't express
the pencil-only/running-clock scenario Finding 1 fixes, and wasn't faithful
to production's `!undoStack.isEmpty`. Changed the default to
`!userCells.isEmpty` alone (elapsedSeconds decoupled), with an explicit
`canUndo` override where the two must diverge (the `almostCompleteClues`
fixtures encode their near-solved state as puzzle givens, not `userCells`).
Added test coverage in `BoardLeaveOrPauseStateTests` pinning: a running
clock with no move made (pencil-only) resolves to `.pause`; a running clock
with a move resolves to `.pause`; the live-session Ready window is
reachable; and a resumed construction with `initialCanUndo` has no
transient `.leaveReady`.

One additional legitimate re-record from this round: BoardViewPencilNotesTests
now correctly shows Pause (was incorrectly showing Leave under the old
canUndo-only gate, since a pencil-only board has real elapsed time but no
undo history — exactly Finding 1's motivating bug).

Closes #849

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(l10n): loader .failed copy "Couldn't load saved game." is not in the catalogs (both loaders)

1 participant