test: Validate local files are valid - #8179
Conversation
| .filter((f) => f.endsWith('.json')) | ||
| .map((f) => join(localesDir, f)); | ||
|
|
||
| const macroRe = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)((\s*([a-zA-Z]+): ?([ a-zA-Z{}]+),?)+)*\s*]}/g; |
| .filter((f) => f.endsWith('.json')) | ||
| .map((f) => join(localesDir, f)); | ||
|
|
||
| const macroRe = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)((\s*([a-zA-Z]+): ?([ a-zA-Z{}]+),?)+)*\s*]}/g; |
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoValidate locale JSON structure and translation macros
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Italian macro remains unfixed
|
| for (const [key, value] of Object.entries(parsed)) { | ||
| if (key === '@metadata') continue; | ||
| let match; | ||
| while ((match = macroRe.exec(value)) !== null) { |
There was a problem hiding this comment.
2. Malformed macros evade validation 🐞 Bug ≡ Correctness
The validation loop only checks strings that fully match macroRe, so malformed macro candidates
are silently skipped; existing Hungarian and Unicode locale entries pass this test even though the
runtime cannot expand them and displays the raw {[...]} markup. This prevents the test from
enforcing its stated guarantee that the locale corpus contains no unsupported macros.
Agent Prompt
## Issue description
The locale validator only inspects complete `macroRe` matches, allowing malformed or runtime-unsupported `{[...]}` expressions to pass unnoticed.
## Issue Context
The runtime uses similarly restrictive syntax and leaves unmatched macro text in the rendered translation. Scan for every macro candidate, validate that the entire candidate conforms to supported syntax, and report malformed candidates; update currently invalid locale entries so the strengthened test passes.
## Fix Focus Areas
- src/tests/backend-new/specs/locale-files.test.ts[13-39]
- src/locales/hu.json[161-161]
- src/locales/diq.json[162-162]
- src/locales/shn.json[109-109]
- src/locales/my.json[152-152]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This test will check for translation errors in the future and should prevent #8163