Skip to content

i18n: tighten placeholder, tag, and ICU select validation - #1344

Closed
kruschdev wants to merge 1 commit into
pascalorg:mainfrom
kruschdev:fix/i18n-validation
Closed

kruschdev wants to merge 1 commit into
pascalorg:mainfrom
kruschdev:fix/i18n-validation

Conversation

@kruschdev

@kruschdev kruschdev commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Split out of #1310 as the tooling-only slice (Slice 1) from the #1148 review follow-ups.

  • Tightens placeholder, rich-text tag (numbered tags, nesting, HTML/comment tags), and ICU select branch validation in scripts/i18n.ts.
  • Adds regression tests covering each validation case in scripts/i18n.test.ts.

Verification

  • bun test scripts/i18n.test.ts (13/13 pass)
  • biome check clean (0 issues)

Part of #1155.


Note

Medium Risk
Stricter validation can fail existing PO entries or AI drafts that previously passed; impact is limited to i18n tooling, not runtime app logic.

Overview
Strengthens translation validation in scripts/i18n.ts (validateTranslation), which runs during catalog check/compile and when rejecting invalid AI provider output.

Rich-text tags: Tag parsing is refactored via extractTags so comparisons like Width < 5 m are not treated as markup. Validation still requires the same tag set as English (so renumbered <0> vs <1> fails), and adds tagNestingErrors for malformed or crossed nesting. Stricter detection flags injected HTML/comments/unclosed tags (e.g. <img/src=...>, <!-- -->) when English has no tags.

ICU plurals & selects: Plural rules now always require an other branch (including when English omitted it). New selects() logic enforces that translations keep every English select branch and include other, with specific error messages for missing branches.

Tests: scripts/i18n.test.ts adds regression coverage for nesting, numbered tags, malicious-looking markup, select branches, and plural other.

Reviewed by Cursor Bugbot for commit 32ec36e. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 32ec36e. Configure here.

Comment thread scripts/i18n.ts
const type = token[1]
const choices = token[2]
if (type === 'select' && choices && typeof choices === 'object') {
found.set(token[0], new Set(Object.keys(choices)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Select parser overwrites duplicate selectors

Low Severity

selects stores each selector name with Map.set, so a later select with the same name replaces the earlier branch set. Validation then only checks that last occurrence. A translation can drop branches from an earlier or nested select of the same name and still pass, including the new missing-branch checks.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 32ec36e. Configure here.

@Aymericr Aymericr added the bot:tooling label Dec 2, 2026 — with Cursor
Aymericr added a commit that referenced this pull request Dec 2, 2026
* core: slide door with transom to full opening height on sloped walls

Ported from #1304 (head 4a50d00).

Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com>

* viewer,editor: defer wall T-junction repair to export preparation

Ported from #1309 (head b063e9c).

Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com>

* i18n: tighten placeholder, tag, and ICU select validation

Ported from #1344 (head 32ec36e).

Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com>

* core(i18n): apply per-fallback-locale plural rules in PascalI18n

Ported from #1345 (head 03da2d2).

Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com>

* Revert "core(i18n): apply per-fallback-locale plural rules in PascalI18n"

This reverts commit f936404.

Co-authored-by: Aymeric Rabot <Aymericr@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com>
Co-authored-by: Aymeric Rabot <Aymericr@users.noreply.github.com>

Aymericr commented Dec 2, 2026

Copy link
Copy Markdown
Member

Thanks @kruschdev! This landed on main in #1347 (squash 4047d44), with you credited as co-author. One follow-up from review: when a message has several select expressions on the same variable, selects() keeps only the last one, so an earlier occurrence could lose a branch and still pass. A small follow-up PR comparing every occurrence would be welcome. Closing this one as merged via #1347.

@Aymericr Aymericr closed this Dec 2, 2026
Aymericr pushed a commit that referenced this pull request Dec 3, 2026
Co-authored-by: kruschdev <kruschdev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants