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

Zend_Currency with PHP setLocale (de_DE) conflict #706

Open

Description

@solverat

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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions