moneyphp/money

numberFormat refuses to use comma as decimal separator.

getJv opened this issue · 2 comments

getJv commented

Hello all,

The snippet below is returning "€ 1,234,567.89", stead of "€ 1.234.567,89".

I already tried a different number of configs but with no success:

  • locale as it_IT or nl_NL
  • Set the system locale to Berlinin the Alpine Container
  • different kinds of patterns, etc

Do any of you know what should be done to use commas as decimal operator with this lib?

   $money = new Money('123456789', new Currency('EUR'));
   $currencies = new ISOCurrencies();
   $numberFormatter = new \NumberFormatter('de_DE', \NumberFormatter::CURRENCY);
   $numberFormatter->setPattern('¤ #,##0.###'); //#.##0,00
   $moneyFormatter = new IntlMoneyFormatter($numberFormatter, $currencies);
   echo $moneyFormatter->format($money);

Did you create your Alpine container with the icu-data-full package installed before compiling PHP?