fix(i18n): stop matching STALE-commented lines as live, revive 56 wrongly-dead keys (FIX-I18N-STALE-COMMENT-PARSING) - #119
Merged
Conversation
Grilled with docs, 2026-08-10. Also cleans up dev/roadmap.md: removes the FEAT-MOVING-ZONE entry (duplicate of already-merged PR #49), marks ctld-tools modTypes validation as done (FIX-VALIDATE-MODTYPES, PR #87), and marks the unit:/group: schema metadata entry as apparently already delivered (no dedicated lot found). No ADR - fixing a comment-blind regex across three call sites is a bug fix, not a design trade-off with alternatives to record.
The shared dict parser (i18n_dict_utils.py), generate_i18n_dicts.ps1's Get-DictKeys, and translate_i18n.py's _apply_translations all matched a "ctld.i18n[...] = ..." line regardless of a "-- STALE: " comment prefix, making a dead key indistinguishable from a live one. All three now skip any line starting with "--". Re-running the corrected generate_i18n_dicts.ps1 -Apply surfaced a production bug far bigger than the originally-scoped KO/ES cosmetic drift: 56 keys - every HAWK/BUK/KUB/NASAMS/Patriot/S-300 AA system label, several F10 menu labels, and 7 vehicle-category labels - were wrongly marked -- STALE: in all four dictionaries including English, almost certainly predating generate_i18n_dicts.ps1's config-YAML desc/name scan (these keys are referenced there, not via ctld.tr()). At runtime this meant ctld.i18n["en"]["HAWK Launcher"] and 55 others were nil - broken/missing F10 and AA-system text in every language. -Apply revives all 56 (EN's text restored automatically since EN's value always equals its key). The FR/ES/KO translations sitting inert in the old commented lines were hand-recovered into the freshly revived entries rather than lost or re-translated from scratch. Genuinely new stubs (7 category labels in KO/ES, 15 never-translated KO labels) are left empty for a future translation pass. pytest tools/build/ 24/24 green (5 new tests). luac -p clean on all 4 dictionaries. Final dry-run: OK on all four. See .backlog/FIX-I18N-STALE-COMMENT-PARSING/.
Reviewer's GuideFixes i18n tooling so Sequence diagram for i18n translation applying with STALE-line exclusionsequenceDiagram
participant Dev
participant translate_i18n_py as translate_i18n_py
participant i18n_dict_utils as i18n_dict_utils_py
participant CTLD_i18n as CTLD_i18n_xx_lua
Dev->>translate_i18n_py: run translate_i18n.py
translate_i18n_py->>CTLD_i18n: read dict file text
translate_i18n_py->>i18n_dict_utils: parse_dict(text)
i18n_dict_utils-->>translate_i18n_py: {key: value} (STALE lines skipped)
translate_i18n_py->>translate_i18n_py: _collect_stubs(en_dict)
translate_i18n_py->>translate_i18n_py: _apply_translations(path, translations, lang)
alt line starts with --
translate_i18n_py->>translate_i18n_py: [pattern does not match]
translate_i18n_py-->>Dev: count unchanged for STALE key
else live entry line
translate_i18n_py->>translate_i18n_py: pattern.subn(replacement, text)
translate_i18n_py->>CTLD_i18n: write updated dict file
translate_i18n_py-->>Dev: count incremented for live key
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider applying translations in a deterministic order (e.g., iterating over
sorted(translations)in_apply_translations) so dictionary diffs stay stable and easier to review across runs. - The key-matching regex and comment-skipping logic are now duplicated between
parse_dictandGet-DictKeys; it may be worth centralizing or clearly documenting a single canonical pattern to reduce the risk of future divergence.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider applying translations in a deterministic order (e.g., iterating over `sorted(translations)` in `_apply_translations`) so dictionary diffs stay stable and easier to review across runs.
- The key-matching regex and comment-skipping logic are now duplicated between `parse_dict` and `Get-DictKeys`; it may be worth centralizing or clearly documenting a single canonical pattern to reduce the risk of future divergence.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
5 tasks
FullGas1
added a commit
that referenced
this pull request
Aug 10, 2026
…T-REPAYMENT-2) (#120) * fix(i18n): repay KO/ES debt from the revived stale keys (FIX-I18N-DEBT-REPAYMENT-2) Follow-up to FIX-I18N-STALE-COMMENT-PARSING (PR #119), which revived 56 keys wrongly marked -- STALE: in all four dictionaries. 22 KO + 7 ES entries among them were genuine debt - never translated even before that bug. EN/FR were already complete. Same method as FIX-I18N-DEBT-REPAYMENT: direct translation, no ANTHROPIC_API_KEY available and the Claude Code CLI fallback can't be invoked from a nested Claude Code session. FARP / FOB added to __keep_en for both languages (acronym, no translatable content). pytest tools/build/ 24/24 unchanged; generate_i18n_dicts.ps1 dry-run reports OK on all four dictionaries. Lot: .backlog/FIX-I18N-DEBT-REPAYMENT-2/. * chore(backlog): mark FIX-I18N-DEBT-REPAYMENT-2 as merged (PR #120)
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
i18n_dict_utils.py),generate_i18n_dicts.ps1'sGet-DictKeys, andtranslate_i18n.py's_apply_translationsall matched actld.i18n[...] = "..."line regardless of a-- STALE:comment prefix, making a dead key indistinguishable from a live one. All three now skip any line starting with--.generate_i18n_dicts.ps1 -Applysurfaced that 56 keys - every HAWK/BUK/KUB/NASAMS/Patriot/S-300 AA system label, several F10 menu labels, and 7 vehicle-category labels - were wrongly marked-- STALE:in all four dictionaries including English, almost certainly predating the script's config-YAMLdesc:/name:scan (these keys are referenced there, not viactld.tr()). At runtime this meantctld.i18n["en"]["HAWK Launcher"]and 55 others werenil- broken/missing F10 and AA-system text in every language, not a KO/ES-only cosmetic issue. This is a live production bug fix, not just a parsing correctness improvement.-Applyrevived all 56 keys (EN's text restored automatically, since EN's value always equals its key). The FR/ES/KO translations sitting inert in the old commented lines were hand-recovered into the freshly revived entries rather than lost or re-translated from scratch. Genuinely new stubs (7 category labels in KO/ES, 15 never-translated KO labels - all pre-existing debt unrelated to this bug) are left empty for a future translation pass.MISSING/STALEclassification rules - only to how "present in a dictionary" is determined.check_i18n_diff.pyneeded no code change (inherits the fix via the shared parser)..backlog/FIX-I18N-STALE-COMMENT-PARSING/- PRD plus 1 ticket.Test plan
Generated with Claude Code
Summary by Sourcery
Fix i18n tooling to ignore stale commented entries and revive wrongly-stale AA system and F10/menu labels across all languages.
Bug Fixes:
Enhancements:
Documentation:
Tests: