Skip to content

Add ICU-aware parameter completion and inspections for translations - #2918

Merged
Haehnchen merged 1 commit into
Haehnchen:masterfrom
Kocal:feat/translation-icu-parameters
Nov 13, 2026
Merged

Haehnchen merged 1 commit into
Haehnchen:masterfrom
Kocal:feat/translation-icu-parameters

Conversation

@Kocal

@Kocal Kocal commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Completing parameters keys for messages from +intl-icu files (Twig |trans, |transchoice, |trans_html, PHP trans(), TranslatableMessage, t()) now suggests the ICU argument names with their type (number, date or string) and the options of a select, instead of broken entries like {sum, number}. Unquoted Twig keys such as {total: …} are completed too.

New weak-warning inspections in PHP and Twig report a parameter that matches no argument of the message in any locale. They stay silent when the message is not ICU, has a syntax error, or the key or domain is not a literal.

Messages are read with a small parser that follows ICU4J's MessageFormat grammar, because ICU4J is not bundled in every IDE (it is missing from PhpStorm 2026.3).

Given home.oss.project_aria_label: '{sum, number} contributions on {label}: {reviews, number} reviews, {prs, number} pull requests' translation:
Capture d’écran 2026-11-13 à 10 59 52

Capture d’écran 2026-11-13 à 11 00 21

Completing `parameters` keys for messages from `+intl-icu` files (Twig `|trans`, `|transchoice`, `|trans_html`, PHP `trans()`, `TranslatableMessage`, `t()`) now suggests the ICU argument names with their type (`number`, `date` or `string`) and the options of a `select`, instead of broken entries like `{sum, number}`. Unquoted Twig keys such as `{total: …}` are completed too.

New weak-warning inspections in PHP and Twig report a parameter that matches no argument of the message in any locale. They stay silent when the message is not ICU, has a syntax error, or the key or domain is not a literal.

Messages are read with a small parser that follows ICU4J's MessageFormat grammar, because ICU4J is not bundled in every IDE (it is missing from PhpStorm 2026.3).
@Haehnchen

Copy link
Copy Markdown
Owner

👍

@Haehnchen
Haehnchen merged commit e9c9af1 into Haehnchen:master Nov 13, 2026
1 check passed
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.

2 participants