Localized text needs grammar that depends on a value you only know at runtime — the right article, the right ending, the right particle. Here is every form this library can produce for whatever you type, with the part it added highlighted.
stem unchanged ending added by the library letter the stem had to change
The same thing inside a localized string. Anything between
^[ and ] gets inflected, and
{placeholders} are substituted first — so the grammar agrees with the runtime
value, not with whatever the translator happened to write.
Grammar names sound forbidding and mean simple things. Each one below answers a question you already ask in English with a preposition.
// zero dependencies, a few kB, browser and Node npm install i18n-inflect // import only the languages you need import { format, inflect } from "i18n-inflect"; import "i18n-inflect/hu"; format("hu", "Nyertél ^[a {card}](case: instrumental)!", { card: "kőr ász" }); // → "Nyertél a kőr ásszal!"
Eleven languages today — Hungarian, English, German, French, Spanish, Italian, Portuguese, Polish, Russian, Turkish, Korean. If a form comes out wrong in yours, that is worth an issue even without a fix.