yiisoft / i18n

Yii i18n
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
24 stars 26 forks source link

Add region to Locale::language() or some method returns language-region #35

Closed Gerych1984 closed 2 years ago

Gerych1984 commented 2 years ago

Good day. In my case i set Application::charset as ru-RU. It works for any IntlMessageFormatter without currency pattern. For example

<?php

$value = '1419326100';
echo $formatter->format('{0, number, integer}', [$value], $locale->language());  //1 419 326 100
echo $formatter->format('{0, number, currency}', [$value], $locale->language());  //1 419 326 100,00 XXXX
echo $formatter->format('{0, number, currency}', [$value], $locale->language() . '-' . $locale->region());  //1 419 326 100,00 ₽

So - can you append region (if it set) to language or some short method who return locale as language-region format. Thanks

samdark commented 2 years ago

IntlMessageFormatter works well with $locale->asString(). Do you want to trim everything except language and region?

Gerych1984 commented 2 years ago

IntlMessageFormatter works well with $locale->asString(). Do you want to trim everything except language and region?

Hm, sorry my mistake - i forgot about this method. And with this it work well