Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Zend_Currency with PHP setLocale (de_DE) conflict #706

Open
solverat opened this issue Jun 20, 2016 · 0 comments
Open

Zend_Currency with PHP setLocale (de_DE) conflict #706

solverat opened this issue Jun 20, 2016 · 0 comments

Comments

@solverat
Copy link

preparation

  • set setlocale(LC_ALL, "de_DE.utf8");
  • check if bcmath is installed on your server
  • check if the german locale is installed on your server (de_DE.utf8), check this command via ssh: $ locale -a)

test

$currency = new \Zend_Currency('de_DE');
echo $currency->toCurrency(22, array('symbol' => 'EURO'));

instead of 22,00 you should see 220,00.

stacktrace

-> trigger \Zend_Currency::toCurrency()
--> triggers \Zend_Locale_Format::toNumber()
---> triggers \Zend_Locale_Math:: round()

$op1 .= '.0';

Zend adds an .0 to a number.

---> triggers \Zend_Locale_Math:: normalize()
https://github.com/zendframework/zf1/blob/master/library/Zend/Locale/Math.php#L177

$convert = localeconv();
$value = str_replace($convert['thousands_sep'], "",(string) $value); 
//thousands_sep in de_DE is a .

so this replace transforms 70.0 into 700.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants