Skip to content

Add Translation Management section for admin UI translation synchronization - #81

Closed
DutchmanNL with Copilot wants to merge 4 commits into
mainfrom
copilot/synchronize-translation-files
Closed

Add Translation Management section for admin UI translation synchronization#81
DutchmanNL with Copilot wants to merge 4 commits into
mainfrom
copilot/synchronize-translation-files

Conversation

Copilot AI commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

ioBroker adapters with JSON-Config admin interfaces require translation files in 11 languages to stay synchronized with admin/jsonConfig.json. The automated npm run translate command adds new keys but doesn't remove orphaned ones, leading to recurring PR review issues.

Changes

  • Translation Management section in template.md

    • Workflow for updating translations when modifying admin/jsonConfig.json
    • Critical rules: key matching, orphaned key prevention, native language requirement, alphabetical sorting
    • Validation script to detect missing/orphaned keys across all 11 languages
    • Common pitfalls from real adapter PRs (e.g., English fallbacks in non-English files)
    • Pre-commit validation checklist
  • Version bump to 0.6.0

    • Updated metadata.json, package.json, template.md, copilot-instructions.md
    • CHANGELOG.md entries for v0.6.0

Validation Script Example

const fs = require('fs');
const jsonConfig = JSON.parse(fs.readFileSync('admin/jsonConfig.json', 'utf8'));

function extractTexts(obj, texts = new Set()) {
    if (typeof obj === 'object' && obj !== null) {
        if (obj.label) texts.add(obj.label);
        if (obj.help) texts.add(obj.help);
        for (const key in obj) extractTexts(obj[key], texts);
    }
    return texts;
}

const requiredTexts = extractTexts(jsonConfig);
const languages = ['de', 'en', 'es', 'fr', 'it', 'nl', 'pl', 'pt', 'ru', 'uk', 'zh-cn'];

languages.forEach(lang => {
    const translations = JSON.parse(fs.readFileSync(`admin/i18n/${lang}/translations.json`, 'utf8'));
    const missing = [...requiredTexts].filter(t => !translations[t]);
    const orphaned = Object.keys(translations).filter(k => !requiredTexts.has(k));
    
    console.log(`\n=== ${lang} ===`);
    if (missing.length) console.log('❌ Missing:', missing);
    if (orphaned.length) console.log('❌ Orphaned (REMOVE):', orphaned);
    if (!missing.length && !orphaned.length) console.log('✅ All keys match!');
});

The script identifies discrepancies between jsonConfig.json and translation files, preventing the "10+ review comments" scenario documented from ioBroker.bambulab PR #248.

Original prompt

This section details on the original issue you should resolve

<issue_title>Translation files must stay synchronized</issue_title>
<issue_description>adopt https://github.com/DrozmotiX/ioBroker.bambulab/pull/248/changes#diff-227c2c26cb2ee0ce0f46a320fc48fbcbdf21801a57f59161b1d0861e8aad55f5</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 16, 2026 22:34
…#65)

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
…generic

Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix synchronization of translation files Add Translation Management section for admin UI translation synchronization Feb 16, 2026
Copilot AI requested a review from DutchmanNL February 16, 2026 22:38
@DutchmanNL
DutchmanNL marked this pull request as ready for review February 17, 2026 07:07
Copilot AI review requested due to automatic review settings February 17, 2026 07:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds new template guidance to help ioBroker adapter maintainers keep JSON-Config admin UI translation files synchronized with admin/jsonConfig.json, and bumps the template/package version to 0.6.0.

Changes:

  • Added a “Translation Management” section (workflow + validation script example) to template.md.
  • Bumped version references to 0.6.0 across template, package, metadata, README, and repo instructions.
  • Added 0.6.0 changelog entries describing the translation-management addition.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
template.md Adds Translation Management guidance, validation script example, and workflow/checklist for i18n key synchronization.
package.json Bumps package version to 0.6.0.
config/metadata.json Bumps main and template version to 0.6.0.
README.md Updates the displayed template version snippet to 0.6.0.
CHANGELOG.md Adds a 0.6.0 section documenting the translation-management change.
.github/copilot-instructions.md Bumps repository instructions version to 0.6.0.

Comment thread template.md
Comment on lines +639 to +643
if (typeof obj === 'object' && obj !== null) {
if (obj.label) texts.add(obj.label);
if (obj.help) texts.add(obj.help);
for (const key in obj) {
extractTexts(obj[key], texts);

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

The validation script example adds obj.label / obj.help values to the Set without checking they are strings. In JSON-Config these fields can be language objects (or other non-string values), which would lead to incorrect keys (e.g., objects) and false missing/orphaned reports. Consider only collecting string values (or explicitly handling { en: ... } forms) before adding them to the set.

Suggested change
if (typeof obj === 'object' && obj !== null) {
if (obj.label) texts.add(obj.label);
if (obj.help) texts.add(obj.help);
for (const key in obj) {
extractTexts(obj[key], texts);
if (obj && typeof obj === 'object') {
const collectTextValue = (value) => {
if (typeof value === 'string') {
texts.add(value);
} else if (value && typeof value === 'object') {
// Handle language objects like { "en": "Name", "de": "Name" }
if (typeof value.en === 'string') {
texts.add(value.en);
}
for (const v of Object.values(value)) {
if (typeof v === 'string') {
texts.add(v);
}
}
}
};
if (obj.label) collectTextValue(obj.label);
if (obj.help) collectTextValue(obj.help);
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
extractTexts(obj[key], texts);
}

Copilot uses AI. Check for mistakes.
Comment thread template.md
- **Location**: `admin/i18n/{lang}/translations.json` for 11 languages (de, en, es, fr, it, nl, pl, pt, ru, uk, zh-cn)
- **Source of truth**: `admin/jsonConfig.json` - all `label` and `help` properties must have translations
- **Command**: `npm run translate` - automatically generates translations but does NOT remove orphaned keys
- **Formatting**: English uses tabs, other languages use 4 spaces (per ioBroker standards)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

The statement about JSON formatting (“English uses tabs, other languages use 4 spaces”) is likely inaccurate/misleading since JSON whitespace is not semantically relevant and formatting depends on the tool/editor. Suggest removing this rule or rephrasing it to a tool-agnostic recommendation (e.g., run formatter/keep consistent formatting).

Suggested change
- **Formatting**: English uses tabs, other languages use 4 spaces (per ioBroker standards)
- **Formatting**: Use a consistent JSON formatting/indentation style across all languages (preferably via your project’s formatter or editor’s JSON format command).

Copilot uses AI. Check for mistakes.
Comment thread CHANGELOG.md
Comment on lines +15 to +16
## [0.6.0] - 2026-02-16
- (copilot) **NEW**: Added comprehensive Translation Management section to template.md with detailed instructions for keeping translation files synchronized with admin/jsonConfig.json (Fixes #65)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

Changelog entry references “(Fixes #65)”, but the PR description indicates this change should fix issue #80. Please update the issue reference so the changelog matches the PR/linked issue.

Copilot uses AI. Check for mistakes.
@DutchmanNL

Copy link
Copy Markdown
Contributor

rebuild PR in #83

@DutchmanNL DutchmanNL closed this Feb 17, 2026
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.

Translation files must stay synchronized

3 participants