Code like count === 1 ? "file" : "files" works in English and breaks in languages with more plural forms. Intl.PluralRules tells you which category a number falls in, so you only supply the words.
const plural = new Intl.PluralRules("en-US");
const label = { one: "file", other: "files" };
const n = 3;
`${n} ${label[plural.select(n)]}`; // "3 files"
const ordinal = new Intl.PluralRules("en-US", { type: "ordinal" });
const suffix = { one: "st", two: "nd", few: "rd", other: "th" };
[1, 2, 3, 4, 11, 12, 21, 22].map((n) => n + suffix[ordinal.select(n)]);
// 1st 2nd 3rd 4th 11th 12th 21st 22nd
select() returns a category name: zero, one, two, few, many or other. Which ones a language uses differs. English cardinals only have one and other, while Polish or Arabic use more. You keep a small object of words per language, and the rules come from the browser.
The ordinal version is my favourite part. It knows that 11, 12 and 13 take “th” while 21, 22 and 23 do not, which is the bit people get wrong when they write it by hand.
Two caveats. The categories are not numbers: one in some languages also covers 21 or 0.5, so always map by category and never assume “one means 1”. And the result only gives you the category; the words themselves still need translating. Support is old and broad: Chrome 63, Firefox 58 and Safari 13.
Further reading: MDN: Intl.PluralRules, MDN: Intl.PluralRules.prototype.select()