Lint rules
inconsistent-args
errorFlags a translation whose ICU features don't match the source message.
Why this is bad
Placeholders are the contract between your code and a message.
A translation breaks it when it:
- drops an argument or tag, which may needlessly generalize the sentence
- invents an argument or tag, which throws at runtime
- breaks the ICU syntax, so the message can't be formatted
- drops a select, which loses the text of its branches
- prints a value through a different formatter, e.g. a number without its digit grouping or a date as a raw timestamp
Examples
Given this source message:
messages/en.json
{"delete": "Delete {item} ({size, number} KB)"}
Examples of incorrect code for this rule:
messages/fr.json
{"delete": "Supprimer cet élément ({size, number} Ko)"}
(absent argument)
messages/fr.json
{"delete": "Supprimer {objet} ({size, number} Ko)"}
(translated argument)
messages/fr.json
{"delete": "Supprimer l'{item} ({size, number} Ko)"}
(apostrophe escapes argument)
messages/fr.json
{"delete": "Supprimer l''{item} ({size} Ko)"}
(number formatter dropped)
Examples of correct code for this rule:
messages/fr.json
{"delete": "Supprimer l''{item} ({size, number} Ko)"}
(apostrophe escaped too)
How to fix it
Re-translate the message for the flagged locale with eloqnt translate. Passing --id replaces the existing translation, and the post-translation checks reject any attempt whose arguments differ from the source.
npx eloqnt translate --id delete --locale fr
To fix it manually, use every argument the way the source does.