yii2: Ability to set currency symbol in formatter do not working

What steps will reproduce the problem?

I’m configure my frontend/config/main.php:

'language' => 'ru-RU',
    'components' => [
        ...
        'formatter' => [
            'dateFormat' => 'dd.MM.yyyy',
            'decimalSeparator' => ',',
            'thousandSeparator' => ' ',
            'currencyCode' => 'RUB',
            'numberFormatterOptions' => [
                NumberFormatter::MIN_FRACTION_DIGITS => 0,
                NumberFormatter::MAX_FRACTION_DIGITS => 2,
            ],
            'numberFormatterSymbols' => [
                NumberFormatter::CURRENCY_SYMBOL => '₽',
            ]
        ],
    ],

What is the expected result?

When i writting

<?= Yii::$app->formatter->asCurrency(100000) ?>

i expect to see 100 000 ₽ (my symbol)

What do you get instead?

but i get 100 000,00 руб.

Additional info

When i setting parameter numberFormatterSymbols, parameter numberFormatterOptions not working after (before result was 100 000 руб.)

Q A
Yii version 2.0.11.2?
PHP version 7.1.0
Operating system ubuntu/trusty64
and i testing too on native vagrant settings of yii2 same result

thats my first issue, sry if something wrong

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Here’s what I’ve found so far:

  • 58.2 — works
  • 58.1 — works
  • 57.1 — works
  • 56.1 — works
  • 55.1 — does not work
  • 54.1 — does not work
  • 52.1 — does not work
  • 51.2 — does not work
  • 49.1.2 — does not work
  • 4.8.1.1 — does not work

Sorry, a little out of topic, but, I want to set my thousand (.) and decimal (,) separator in my currency (example: Rp 12.500,50). My formatter code:

        'formatter' => [
            'defaultTimeZone' => 'UTC',
            'timeZone' => 'Asia/Jakarta',
            'dateFormat' => 'php:d-m-Y',
            'datetimeFormat' => 'php:d-M-Y H:i:s',
            'decimalSeparator' => ',',
            'thousandSeparator' => '.',
            'currencyCode' => 'Rp ',
            'numberFormatterOptions' => [
                NumberFormatter::MIN_FRACTION_DIGITS => 0,
                NumberFormatter::MAX_FRACTION_DIGITS => 2,
            ],
        ],

The output is Rp 12.500.50 <- decimal is . I’m expecting Rp 12.500,50 <- decimal is ,

What went wrong? Thanks.