开发者

Displaying locale percentage number with Zend Framework

开发者 https://www.devze.com 2022-12-22 00:21 出处:网络
Does anyone know how to display a percentage format based on the locale using the zend framework?I\'ve tried this below and it doesn\'t work for some reason:

Does anyone know how to display a percentage format based on the locale using the zend framework? I've tried this below and it doesn't work for some reason:

$xx = Zend_Locale::getTranslation(null, 'PercentNumber'); // This outputs: "#,##0%" for locale 'en_us'
$percentage = Zend_Locale_Format::getNumber(133.3678, array('number_format' => $xx, 'locale' => $lan开发者_如何学编程g_LOCALE));

The output of $percentage is 133.3678.

Thanks.


That's somewhat true, in Arabic it is a different Unicode character: ٪ (U+066A), not the same as % (U+0025).


See http://php.net/manual/en/class.numberformatter.php


There is no need in localizing a %. (Researched by checking out the Percentage article in Wikipedia)

Every country in the world uses the notation x % where x is 1 out of 100. The only difference is the number-representation: 1.00 in English for instance while 1,00 in Dutch. Arabic countries write right-to-left, thus % x.

I bet you can find out how to format numbers in Zend.

0

精彩评论

暂无评论...
验证码 换一张
取 消