A
A
Albert Tobacco2015-08-11 18:09:51
Yii
Albert Tobacco, 2015-08-11 18:09:51

Why does the formatter see itself differently in Yii2?

'formatter' => [
            'locale' => 'en-US',
            'decimalSeparator' => '.',
            'thousandSeparator' => ' ',
            'currencyCode' => '$',
        ]

Here is a config that works fine on a dev server. but I throw out ekspeshsh
Formatting currency value failed: 1 Number formatting failed: U_ILLEGAL_ARGUMENT_ERROR

'formatter' => [
            'locale' => 'en-US',
            'decimalSeparator' => '.',
            'thousandSeparator' => ' ',
            'currencyCode' => 'USD',
        ]

This is how it works fine locally, but on the dev server I get strings like "USD 100" and I want to receive "$ 100".
What's wrong ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Klyuev, 2015-08-12
@BBird

Check if you and the server have ext_intl installed, the ext_intl version is puffy.
In general, 'currencyCode' should be a 3-letter currency code, but not $.
The symbol can be added like this (in the example, the tenge sign):

'formatter' => [
            ...
            'numberFormatterSymbols' => [
                NumberFormatter::CURRENCY_SYMBOL => '₸',
            ]
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question