Skip to content

Add a consistency test over the translation files - #64

Merged
Mincka merged 1 commit into
mainfrom
test/translation-parity
Jul 25, 2026
Merged

Mincka merged 1 commit into
mainfrom
test/translation-parity

Conversation

@Mincka

@Mincka Mincka commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Description

Follow-up to #63, which added the first non-English language file since fr.json.

Nothing in CI currently validates the non-English translation files. hassfest checks strings.json and the English side, and stops there. That means:

  • a missing key falls back to English silently, so the language looks complete while parts of it are not;
  • a {placeholder} renamed or dropped during translation renders the raw token to the user;
  • strings.json and translations/en.json are maintained as byte-identical copies by hand, with nothing enforcing it.

test/test_translations_consistency.py closes all three. It asserts that strings.json and translations/en.json parse to the same content, and for every other translations/*.json: identical leaf-key sets, identical placeholder tokens per key, and no blank strings. New languages are picked up automatically through a glob, with a guard test so an empty glob cannot make the rest pass vacuously.

Paths are resolved from __file__ rather than by importing the integration, so the test needs no homeassistant import and runs in milliseconds.

It follows the shape of the existing test/test_options_consistency.py, which guards the same class of silent drift on the options side.

Scope note: this catches structural drift, not translation quality. The five content errors corrected in #63 (a leftover English fragment, a typo, a mistranslation, two casing errors) were all key-parity-clean and no automated check would have caught them.

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code where necessary
  • I have added tests that are covering all code branches
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

PR #63 added the first non-English language file since fr.json, and
nothing in CI looks at those files: hassfest validates strings.json and
the English side only. A missing key falls back to English silently, and
a placeholder renamed in translation renders the raw token to the user.

The test asserts that strings.json and translations/en.json are
identical, and that every other translations/*.json has the same leaf
keys, the same {placeholder} tokens per key, and no blank strings. It
picks up new languages automatically through a glob, guarded by a test
that the glob is non-empty.

Resolving paths from __file__ rather than importing the integration
keeps the test free of the homeassistant dependency.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Mincka
Mincka merged commit ac8e8ec into main Jul 25, 2026
7 checks passed
@Mincka
Mincka deleted the test/translation-parity branch July 25, 2026 18:31
@Mincka Mincka mentioned this pull request Jul 25, 2026
4 tasks done
Mincka added a commit that referenced this pull request Jul 25, 2026
German translation (#63, thanks @vlntnwbr) and a consistency test over
the translation files (#64).

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Mincka Mincka mentioned this pull request Jul 25, 2026
2 of 9 tasks
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