i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Feature Request: Support delimited numbers for pluralization

Open short-dsb opened this issue 7 months ago • 0 comments

Description

Numbers passed to pluralize via count are not delimited. For example, in en-US:

1234 results

…should be:

1,234 results

Describe the solution

A possible solution is to pass an optional displayCount string that overrides the numeric count in the output. For example:

const resultsCount = 1234;

i18n.t("results", {
  count: resultsCount,
  displayCount: i18n.numberToDelimited(resultsCount),
});

This would give more control over how the output is formatted. For example, if someone wanted to use numberToHuman instead of numberToDelimited.

Alternatives you considered

There’s no alternative to this as far as I can tell, given how count is parsed when a string is pluralized via zero, one, few, many, and other. Happy to be proven wrong. 🙂

Additional context

This is how pluralization works for FBT via PluralOptions.value.

Thanks for all your work on this library!

short-dsb avatar Jul 19 '24 23:07 short-dsb