Skip to content

Fix translated placeholders in translations#1280

Merged
frenck merged 1 commit into
mainfrom
fix/translation-placeholders
May 28, 2026
Merged

Fix translated placeholders in translations#1280
frenck merged 1 commit into
mainfrom
fix/translation-placeholders

Conversation

@frenckatron
Copy link
Copy Markdown
Collaborator

Description

Fixes all translation strings where placeholders no longer match the English source strings.

This touches 39 strings across 10 locale files. Clear placeholder renames, like {titel} and {uređaji}, are corrected in place. Strings that were missing or badly mangled now fall back to the English source string so runtime formatting gets the exact placeholder contract again.

It also adds a regression test that compares placeholders in every locale file with en.json, so translated placeholder names are caught before merge.

Motivation and Context

Placeholders are runtime format keys, not translatable prose. If a locale changes {title} to {titel}, or drops {entity_id}, Home Assistant cannot format the repair text correctly.

We already saw this in a few PRs. This cleans up the remaining cases in one pass and adds a guard for future translation changes.

How has this been tested?

  • python placeholder parity probe against all locale files
  • uv run check-json custom_components/spook/translations/<locale>.json for all translation files
  • uv run pytest tests/test_translations.py -q
  • uv run ruff check tests/test_translations.py
  • uv run ruff format --check tests/test_translations.py
  • uv run pylint tests/test_translations.py

Screenshots (if appropriate):

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@frenckatron frenckatron changed the title Fix translated translation placeholders Fix translated placeholders in translations May 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR corrects translation placeholder mismatches across ten language files and adds automated validation to prevent future inconsistencies. Placeholder keys are standardized to match English templates, malformed placeholders are fixed, and selected translation texts are updated to English equivalents. A new test validates all translations maintain consistent placeholders with the English source.

Changes

Translation placeholder fixes and validation

Layer / File(s) Summary
Translation placeholder and text fixes
custom_components/spook/translations/af.json, custom_components/spook/translations/da.json, custom_components/spook/translations/he.json, custom_components/spook/translations/hr.json, custom_components/spook/translations/ja.json, custom_components/spook/translations/nb.json, custom_components/spook/translations/pt-BR.json, custom_components/spook/translations/sk.json, custom_components/spook/translations/th.json, custom_components/spook/translations/tr.json
Placeholder keys corrected ({titel}{title}, {uređaji}{devices}), malformed placeholders fixed, and translation text updated across multiple languages to align with English template structure and validation expectations.
Translation placeholder consistency test
tests/test_translations.py
New test module validates that all translation files use consistent placeholders matching the English source by recursively comparing placeholder sets and reporting mismatches with their paths and expected vs. actual placeholder lists.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • frenck/spook#1185: Placeholder mismatch in pt-BR translation's lovelace_unknown_entity_references title and description are directly addressed by this PR's corrections.

Possibly related PRs

  • frenck/spook#1166: Both PRs correct the {title} placeholder standardization in user_issue translation keys across language files.
  • frenck/spook#1265: Both PRs fix Home Assistant translation template placeholder mismatches in custom_components/spook/translations/*.json to align placeholders with English validation expectations.
  • frenck/spook#940: Both PRs modify Danish translation content in issues.automation_unknown_label_references with overlapping placeholder and text corrections.

Suggested labels

bugfix

Suggested reviewers

  • frenck

Poem

🐰 A translate-time hop!
Placeholders all set right,
From {titel} to {title},
Tests ensure it stays bright!
No mismatch in sight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix translated placeholders in translations' directly and clearly summarizes the main change: fixing placeholder consistency issues across translation files.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (placeholder format keys must match source strings), scope (39 strings across 10 locale files), and testing approach.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/translation-placeholders

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@frenckatron frenckatron added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label May 28, 2026
@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.38%. Comparing base (c4234a1) to head (257db2f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1280   +/-   ##
=======================================
  Coverage   62.38%   62.38%           
=======================================
  Files         123      123           
  Lines        3126     3126           
  Branches      402      402           
=======================================
  Hits         1950     1950           
  Misses       1128     1128           
  Partials       48       48           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
custom_components/spook/translations/sk.json (1)

225-226: 💤 Low value

Note: Mixed language state in issue entry.

The description (line 225) is now in English while the title (line 226) remains in Slovak. According to the AI summary, this fixes a malformed placeholder (ententity_id}{entity_id}). The English fallback ensures placeholder correctness but creates temporary language inconsistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@custom_components/spook/translations/sk.json` around lines 225 - 226, The
description string under the "description" key is in English while the "title"
remains Slovak, creating a mixed-language entry; replace the English description
with a correct Slovak translation (preserving all placeholders: {automation},
{edit}, {entity_id}, {areas}) so the entry is consistent and the fixed
placeholder `{entity_id}` stays intact; update only the "description" value for
the same keys shown to Slovak and leave "title" as-is.
custom_components/spook/translations/nb.json (1)

249-250: 💤 Low value

Note: Mixed language state in issue entries.

Both group_unknown_members and integration_unknown_source now have English descriptions (lines 249, 253) while their titles (lines 250, 254) remain in Norwegian. This ensures placeholder correctness but creates temporary language inconsistency within each issue entry.

Also applies to: 253-254

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@custom_components/spook/translations/nb.json` around lines 249 - 250, The
JSON entries for group_unknown_members and integration_unknown_source have
English "description" values while their "title" values are Norwegian, causing
mixed-language UI text; update the "description" strings for the keys
group_unknown_members and integration_unknown_source in
custom_components/spook/translations/nb.json so they are fully translated into
Norwegian (preserve placeholders like {group}, {entity_id}, {entities}, etc.),
or alternatively translate the "title" to English if the intent is
English—ensure both title and description are in the same language and that all
placeholders remain unchanged.
custom_components/spook/translations/ja.json (1)

285-286: 💤 Low value

Note: Partial English fallback.

The description (line 285) was updated to English, but the title (line 286) remains in Japanese: "未知の実体: {script}". While the placeholder {script} is correct, this creates an inconsistency within the same issue entry.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@custom_components/spook/translations/ja.json` around lines 285 - 286, The
JSON entry has mixed-language values: the "description" value was changed to
English but the "title" remains Japanese ("未知の実体: {script}"), causing an
inconsistent translation; update the "title" string to an English equivalent
such as "Unknown entity: {script}" (preserve the {script} placeholder exactly)
so both "description" and "title" use English and remain consistent.
custom_components/spook/translations/da.json (1)

242-242: 💤 Low value

Note: Mixed language state in issue entry.

The title is now in English while the description (line 241) remains in Danish. This creates a temporary inconsistency within the automation_unknown_label_references issue entry, though it ensures the placeholder contract is correct.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@custom_components/spook/translations/da.json` at line 242, The "title" value
for the translation entry automation_unknown_label_references is in English
while the rest of that entry is Danish; update the "title" string in
custom_components/spook/translations/da.json
(automation_unknown_label_references.title) to the correct Danish translation
and preserve the placeholder {automation} exactly as-is so the placeholder
contract remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@custom_components/spook/translations/da.json`:
- Line 242: The "title" value for the translation entry
automation_unknown_label_references is in English while the rest of that entry
is Danish; update the "title" string in
custom_components/spook/translations/da.json
(automation_unknown_label_references.title) to the correct Danish translation
and preserve the placeholder {automation} exactly as-is so the placeholder
contract remains unchanged.

In `@custom_components/spook/translations/ja.json`:
- Around line 285-286: The JSON entry has mixed-language values: the
"description" value was changed to English but the "title" remains Japanese
("未知の実体: {script}"), causing an inconsistent translation; update the "title"
string to an English equivalent such as "Unknown entity: {script}" (preserve the
{script} placeholder exactly) so both "description" and "title" use English and
remain consistent.

In `@custom_components/spook/translations/nb.json`:
- Around line 249-250: The JSON entries for group_unknown_members and
integration_unknown_source have English "description" values while their "title"
values are Norwegian, causing mixed-language UI text; update the "description"
strings for the keys group_unknown_members and integration_unknown_source in
custom_components/spook/translations/nb.json so they are fully translated into
Norwegian (preserve placeholders like {group}, {entity_id}, {entities}, etc.),
or alternatively translate the "title" to English if the intent is
English—ensure both title and description are in the same language and that all
placeholders remain unchanged.

In `@custom_components/spook/translations/sk.json`:
- Around line 225-226: The description string under the "description" key is in
English while the "title" remains Slovak, creating a mixed-language entry;
replace the English description with a correct Slovak translation (preserving
all placeholders: {automation}, {edit}, {entity_id}, {areas}) so the entry is
consistent and the fixed placeholder `{entity_id}` stays intact; update only the
"description" value for the same keys shown to Slovak and leave "title" as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f6d74b3-0fbd-49e4-8807-c2b5b3eb3107

📥 Commits

Reviewing files that changed from the base of the PR and between c4234a1 and 257db2f.

📒 Files selected for processing (11)
  • custom_components/spook/translations/af.json
  • custom_components/spook/translations/da.json
  • custom_components/spook/translations/he.json
  • custom_components/spook/translations/hr.json
  • custom_components/spook/translations/ja.json
  • custom_components/spook/translations/nb.json
  • custom_components/spook/translations/pt-BR.json
  • custom_components/spook/translations/sk.json
  • custom_components/spook/translations/th.json
  • custom_components/spook/translations/tr.json
  • tests/test_translations.py

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants