fix: translate app tag arrays - #676
Open
jeroenwienk wants to merge 1 commit into
Open
jeroenwienk wants to merge 1 commit into
jeroenwienk wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation handles the reported failure and is adequately covered by regression tests.
Pull request overview
Adds array-aware manifest translation while preserving existing translations and nested discovery.
Changes:
- Translates English string-array entries individually.
- Skips unsupported source types and avoids API calls for empty arrays.
- Adds regression coverage for arrays, repeat runs, and surrounding fields.
File summaries
| File | Description |
|---|---|
lib/app/Translate.js |
Supports string arrays as translation sources. |
tests/app/translate.test.mjs |
Adds array translation regression tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running
homey app translate --languages nlon a manifest containing"tags": { "en": ["heating", "lighting"] }throwsTypeError: text.match is not a function. The translator treats the English array as a single string, preventing all translation changes in that file from being saved.Change
Recognize English strings and arrays of strings as translation sources. Translate array entries individually and preserve their order and array structure, so missing tag translations and surrounding manifest fields can be saved. Existing translations remain intact, and empty arrays require no API requests. Other English value types are skipped while nested translation objects remain discoverable.
Validation
node --test tests/app/translate.test.mjs— all 10 tests pass. Three new regression tests failed before the fix and pass afterward; they cover tag arrays, surrounding fields, existing translations, repeat runs, empty arrays, and unsupported source values.npm run lint— passes.git diff --check— passes.Translation responses are mocked in the tests; no live API calls were made.