Skip to content

Fix i18n check: context keys (Light|theme) are not plural forms - #540

Merged
elripalda merged 2 commits into
elripalda:mainfrom
dung997tb:fix/i18n-check-context-keys
Nov 25, 2026
Merged

elripalda merged 2 commits into
elripalda:mainfrom
dung997tb:fix/i18n-check-context-keys

Conversation

@dung997tb

Copy link
Copy Markdown
Contributor

Problem

tools/launcher-i18n.py --check reports a false positive for the context key Light|theme in all 22 language files:

en-GB: 1 forms, wants 2: 'Light|theme' -> 'Light'
es: 1 forms, wants 2: 'Light|theme' -> 'Claro'
... (22 in total)

Light|theme is not a plural form and not a coded message. It is a context key used through tc() in ui/app.js:181:

const tc = (k) => { const v = t(k); return v === k ? k.split('|')[0] : v; };

The part after | is a context hint for translators; the translation is a single form (e.g. de Hell, fr Clair, vi Sáng). Giving it two forms would print a literal | on the button. But check() applied the plural-style rule to every key containing |:

if '|' in en:
    want = len(en.split('|'))

Fix

One line: only apply the | rule when the key really is a coded message — i.e. its prefix is an ALL-CAPS code token and the translation preserves that prefix:

if '|' in en and parts[0] == en.split('|')[0] and en.split('|')[0].isupper():
    want = len(en.split('|'))

The two real coded messages, PICK_EXE|... and NEED_COPY|... (emitted from src-tauri/src/lib.rs), keep the old behaviour: their translations keep the code prefix and the two-part structure, and they still pass in every language.

Note the prefix check alone is not enough: en-GB translates Light|theme as Light, whose first segment equals the source's, so it was still flagged. The .isupper() code-token test separates the two cases (there are exactly three | keys in the corpus: Light|theme, PICK_EXE|..., NEED_COPY|...).

Verification

python3 tools/launcher-i18n.py --check before / after:

  • Total errors: 123 → 101 (exactly the 22 Light|theme false positives removed)
  • Light|theme errors: 22 → 0
  • PICK_EXE / NEED_COPY errors: 0 → 0 (unaffected)
  • Diffing the full checker output before/after: the only removed lines are the 22 false positives, and no new errors appear. The remaining 101 errors are pre-existing plural-form issues in other languages, untouched by this PR.

No translation files are changed.

🤖 Fixed with AI assistance (Fable 5.2) and reviewed by the author.

@Xarishark Xarishark self-assigned this Nov 25, 2026
@dung997tb

Copy link
Copy Markdown
Contributor Author

Thanks for building on this, @Xarishark — the coded() helper is a cleaner split than my isupper() guard, and the prefix check closes the hole where a translation drops the code entirely.

I ran the updated checker against the completed Vietnamese translation in #539: vi reports 0 form errors and 0 code-prefix errors. The remaining form errors are pre-existing in other languages (mostly pl). Happy for #540 to land in this shape.

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

All notes resolved and CI passed. Approving.

@elripalda
elripalda merged commit 470c8b2 into elripalda:main Nov 25, 2026
4 checks passed
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.

3 participants