Difference between #2 and #3 of
Getting information from the current locale

Changes

Title unchanged

Getting information from the current locale

Category unchanged

How-tos

Yii version unchanged

2.0

Tags unchanged

i18n,locale,language,formatting rules

Content changed

Yii 2.0 comes with a [formatter component](https://www.yiiframework.com/doc/api/2.0/yii-i18n-formatter) to format dates, numbers, and other values for international users according to their locale. This is very useful for displaying data. When working with incoming data or when using enhanced input methods like the [MaskedInput widget](https://www.yiiframework.com/doc/api/2.0/yii-widgets-maskedinput) you sometimes need to access part the symbols used by the formatter to generate a pattern or parse the input.

The Yii formatter does not have methods to access this data, it relies on the [PHP intl extension](https://secure.php.net/manual/en/book.intl.php) for formatting. If you want to access the formatting symbols you need to work with intl directly.
[...]
```

There are more symbols than shown above, for the full list of
constants see <symbols see the [list of NumberFormatter constants in the php manual](https://secure.php.net/manual/en/class.numberformatter.php#intl.numberformatter-constants.unumberformatsymbol>).

# Getting a currency symbol
[...]
```

Note, that the `NumberFormatter` is instantiated with the `CURRENCY` constant instead of `DECIMAL` here.
 
 
Since Yii 2.0.14 Yii has this method built-in in the [Locale](https://www.yiiframework.com/doc/api/2.0/yii-i18n-locale#getCurrencySymbol()-detail) class.
5 0
2 followers
Viewed: 20 653 times
Version: 2.0
Category: How-tos
Written by: CeBe
Last updated by: CeBe
Created on: Aug 9, 2018
Last updated: 5 years ago
Update Article

Revisions

View all history