Skip to content

feat(app): one-command localization tool; fill missing memory-use labels and drop leftover ARB keys - #14314

Merged
Git-on-my-level merged 8 commits into
mainfrom
task/msd-ui-c6-l10n-tool
Sep 17, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
task/msd-ui-c6-l10n-tool

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Agents were adding user-facing strings by hand across 49 ARB files with jq, then regenerating. python3 app/scripts/l10n.py is now the one command that writes every locale, validates ICU placeholders, regenerates, and formats, so a key cannot land half-translated. A follow-up commit proves it on the memory-edit-sheet baseline-status snackbar (failedToUpdateBaselineStatus).

Review found that the ICU parser treated every apostrophe as an ICU quote, so l10n check false-failed ~420 keys whose English source contains What's / Omi's / Here's before a placeholder (Flutter only quotes apostrophes when use-escaping is true; app/l10n.yaml leaves it unset/false). The parser now reads that setting. After that, check was used to fix the real corpus: memoryAllowUse / memoryDontUse translated into all 48 non-English locales, leftover extra keys English no longer has removed, and Italian selectedCount {s} (which had leaked into the generated selectedCount(int count, Object s) signature) corrected.

Before / after (the manual steps this replaces)

Before

  1. jq --indent 4 the new key (and @key metadata) into app_en.arb only, or run app/scripts/add-l10n-key.sh (English-only; apostrophes in other locales were a known footgun).
  2. Copy the key into the other 48 app_*.arb files by hand or via a translation skill, hoping no locale was skipped.
  3. cd app && flutter gen-l10n and read stderr for "xx": N untranslated message(s).
  4. Optionally add untranslated-messages-file: to l10n.yaml to see which keys were missing, then revert that yaml edit.
  5. dart format --line-length 120 on generated Dart.
  6. Done only when gen-l10n emitted zero untranslated warnings.

After

cd app
python3 scripts/l10n.py template myKey > /tmp/tr.json   # every locale the tree actually has
# fill every value (empty strings are refused)
python3 scripts/l10n.py add myKey --en "English" --description "…" --translations /tmp/tr.json
python3 scripts/l10n.py check   # parse, key-set, placeholders, generated freshness; not wired to a hook

set / remove follow the same shape. Validation failures write nothing. An identical re-run is a no-op. Apostrophes in English (What's New in {version}) are literal unless l10n.yaml sets use-escaping: true.

Product invariants affected

  • INV-MEM-1

Path glob app/lib/pages/memories/** matches memory_edit_sheet.dart. The change is a snackbar string swap (context.l10n.failedToUpdateBaselineStatus); it does not add a memory tier, collection, or default-access path.

How it was verified

  • bash app/test/shell/l10n_tool_test.sh — all cases passed, including apostrophe-before-placeholder, two apostrophes around a placeholder, use-escaping: true refuse/accept, and the existing refusals / byte-exact add.
  • python3 app/scripts/l10n.py check on this tree: exit 0, 8.62s real (user 7.78s). Ready for a pre-push hook; not wired.
  • Corpus repaired with the tool: set memoryAllowUse, set memoryDontUse, 59 removes of extra keys, set selectedCount for the Italian {s} fake placeholder. Extra keys had no context.l10n.<key> references under app/lib (excluding generated Dart). Call site merge_action_bar.dart updated from selectedCount(count, '') to selectedCount(count).
  • cd app && flutter gen-l10n && git diff --exit-code -- lib/l10n — clean. dart run build_runner build --delete-conflicting-outputs && git diff --exit-code -- lib — clean (0 changed, 13s).
  • bash app/test.sh — l10n shell tests passed; Dart suite +2013 ~5 -1. The failure is app/test/unit/search_rank_grouping_test.dart (Bad state: Too many elements); that file is unchanged vs origin/main (git diff origin/main -- app/test/unit/search_rank_grouping_test.dart is empty). Pre-existing on main, not this PR.
  • OMI_PR_BODY_FILE=.local/pr-body-c6.md make preflight — passed, 16 checks in 25.37s.
  • Did not run mobile-verify journeys: the demo is a snackbar string on a leaf sheet, not a navigable screen change. Did not exercise the snackbar or memory-use buttons on a device/simulator.

Tests

  • Core path: app/test/shell/l10n_tool_test.sh — add, template, check, remove, identical re-run, byte-exact append on two real ARB copies; apostrophe / use-escaping accept paths.
  • Error path: same file — existing key, missing locale, unknown locale, placeholder mismatch, flattened plural vs English plural; apostrophe English still refuses a dropped {version}; use-escaping: true refuses a translation that keeps {version} / unquoted {name} against a quoted English source. Each refusal asserts no ARB writes.

Failure class (fixes)

Failure-Class: none

Scoped cleanups (optional)

  • app/scripts/add-l10n-key.sh now exits 2 and points at scripts/l10n.py so the English-only jq path cannot be used by muscle memory.
  • app/AGENTS.md localization section replaced the jq/skill instructions; budget ratcheted down to 167 lines / 11466 bytes.
  • ICU parser follows l10n.yaml use-escaping (repo default false). Found in review as a check false-positive class; fixed with regressions.
  • l10n check freshness re-runs gen-l10n in the real output-dir and restores; a temp output-dir rewrote the import comment in app_localizations.dart and formatted at 80 columns, so check could not exit 0.
  • Translated memoryAllowUse / memoryDontUse; removed 59 extra keys English no longer has; fixed Italian selectedCount.

Part of the mobile self-driving program (App UI lane, package C6). Implemented by Cursor cursor-grok-4.6-high. Coordinator verification on the head commit: bash app/test/shell/l10n_tool_test.sh passed; python3 app/scripts/l10n.py check exits 0 (49 locales, 3071 keys); bash app/scripts/analyze_ratchet.sh passed; both new memory-use labels are present and translated (not English copies) in all 48 non-English locales. The first review round rejected check for an ICU-apostrophe false positive (423 bogus findings); that is fixed here with regression tests.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 5 commits September 17, 2026 07:37
Agents were editing 49 ARB files by hand with jq; this writes every locale, validates ICU placeholders, regenerates, and formats in one step so a new string cannot land half-translated.
The memory edit sheet showed a hardcoded English snackbar; adding the string through the new l10n tool is the proof that one command writes every locale and regenerates cleanly.
Apostrophes are ICU quotes only when Flutter's use-escaping is true.
This repo leaves it unset (false), so What's New in {version} still
declares {version}. The old parser always quoted, so check flagged
every locale that used the placeholder and add refused a matching
translation.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
Generating into a temp output-dir rewrites the import comment in
app_localizations.dart and formats at 80 columns, so check could never
exit 0 on a clean tree. Re-run gen-l10n in the real output-dir, compare,
then restore.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
memoryAllowUse and memoryDontUse were English-only. Extra keys English
no longer has (wantDifferentName, leftover model/onboarding strings)
were unreferenced in app/lib and are removed. Italian selectedCount
had a fake {s} placeholder that leaked into the generated signature.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>

@kodjima33 kodjima33 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.

Feature (one-command localization tool), app area -- approve-only per policy for non-desktop features regardless of diff size. Flagged author elevated scrutiny -- diff reviewed, no abuse signals (no workflows/secrets/eval).

@Git-on-my-level
Git-on-my-level merged commit a299de3 into main Sep 17, 2026
37 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-ui-c6-l10n-tool branch September 17, 2026 19:01
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.

2 participants