Monday, 4 June 2018

NumberFormatter with singular / plural word

Is it possible to use PHP NumberFormatter class to display words in singular or plural depending on the number value using the setPattern method?

This method is using the ICU DecimalFormat library, but I am not familiar with it.

I would like to use plural on the page word when value is more than 1:

$sizeFormatter = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$sizeFormatter->setPattern('#0.# page(s)');



from NumberFormatter with singular / plural word

No comments:

Post a Comment