Skip to content

chore(translations): add locale parity guard and contributor policy - #63

Merged
seevee merged 1 commit into
mainfrom
test/translation-parity-all-locales
Jul 30, 2026
Merged

chore(translations): add locale parity guard and contributor policy#63
seevee merged 1 commit into
mainfrom
test/translation-parity-all-locales

Conversation

@seevee

@seevee seevee commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #58. The translation parity test only guarded translations/en.json, so zh-Hans.json could silently drift as new config-flow steps landed. This extends the guard across every locale file, and settles the policy question that comes with it: what should a lagging translation do to CI?

The split follows who can fix the failure. A stale or misspelled key is the PR author's own doing and is always fixable by them, so it fails. A missing key usually cannot be fixed by whoever added the string, so it warns.

Check Scope Behavior
strings.jsonen.json parity English fails
No keys absent from strings.json every locale fails
Missing keys vs strings.json every locale TranslationDriftWarning
Locale discovery glob fails if it matches nothing

Gating merges on translation completeness would tax feature PRs for no user benefit — Home Assistant falls back to English per key, so a lagging locale is cosmetic. -W error::UserWarning promotes the warning to a failure for a single run if you want to audit.

Locales are found by glob rather than listed, so the next translation is covered the moment it lands.

Changes

  • tests/test_translation_keys_in_sync.py — three new checks (test_locales_discovered, test_translation_has_no_unknown_keys, test_translation_completeness); the two existing English checks are untouched.
  • CONTRIBUTING.md — new "Translations" section: what is enforced, what is best-effort, and how to add a locale.
  • .github/CODEOWNERS (new) — zh-Hans.json owned by @MF-142, scoped to the locale file rather than strings.json so translators aren't pinged on every feature PR.
  • A translations label was created on the repo (not part of this diff).

Test Plan

  • pytest tests -q passes — 478 passed (was 475)
  • ruff check custom_components/ tests/ scripts/ passes
  • ruff format --diff custom_components/ tests/ scripts/ is clean
  • mypy custom_components/cap_alerts passes
  • Loaded in a running Home Assistant instance — n/a, no integration code changed
  • Dependency order respected — n/a, no integration code changed

Both new hard checks were negative-tested: injecting an unknown key and deleting an existing one from zh-Hans.json produced the intended failure and warning respectively, and the file was restored.

Related Issues

Follow-up to #58.

Assisted-by: Claude:claude-opus-5

Extend tests/test_translation_keys_in_sync.py beyond en.json so every file
in translations/ is checked. Locale files must be valid JSON and must not
declare keys absent from strings.json, since a stale key left behind by a
rename never renders.

Missing keys are reported as a TranslationDriftWarning rather than a
failure: Home Assistant falls back to English per key, so a lagging locale
is cosmetic, and the author of a feature PR is usually not the person able
to translate it. Gating merges on it would tax feature contributions to no
user benefit. Use -W error::UserWarning to promote it for a single run.

Locales are discovered by glob so the next translation is covered on
arrival, and test_locales_discovered fails if that glob ever matches
nothing rather than silently collecting no cases.

Document the policy in CONTRIBUTING.md and add .github/CODEOWNERS so the
zh-Hans translator is asked to review edits to their own file.

Assisted-by: Claude:claude-opus-5
@seevee
seevee merged commit 8446211 into main Jul 30, 2026
7 checks passed
@seevee
seevee deleted the test/translation-parity-all-locales branch July 30, 2026 02:44
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.

1 participant