Currency issues
-
When entering “,” as decimal separator and “.” for thousands, and after that entering a balance for a financial account, the systems makes something totally different of it.
A solution would be to not do this yourself, but let php help you. An example (simplified version from my plugin):function zero_decimal_currencies() { # returns an array of currencies that don't have decimals $currency_array = array ( 'BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ); return $currency_array; } $locale = determine_locale(); if (class_exists('NumberFormatter')) $localize_price=1; else $localize_price=0; if ($localize_price) $formatter = new NumberFormatter( $locale."@currency=$cur", NumberFormatter::CURRENCY ); $eme_zero_decimal_currencies_arr=zero_decimal_currencies(); if (in_array($cur,$eme_zero_decimal_currencies_arr)) $decimals = 0; else $decimals=2; // make this an option if ($localize_price) $result = $formatter->formatCurrency($price, $cur); else $result = number_format_i18n($price,$decimals);
This way you can keep a mathematical notation and just show a localized version based on currency ($cur) and the current locale.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Currency issues’ is closed to new replies.