moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.62k stars 440 forks source link

numberFormat refuses to use comma as decimal separator. #752

Closed getJv closed 1 year ago

getJv commented 1 year ago

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:

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);
frederikbosch commented 1 year ago

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

getJv commented 1 year ago

Thank you so much for your help @frederikbosch, that was precisely missing. now my intl is working well.

snipped from my docker file

#... 
RUN apk add --no-cache icu-dev gnu-libiconv gettext tzdata icu-data-full \
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl \
    && docker-php-ext-enable intl
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so
#...