From 646062ef718a64cc9360e1cf69a02e78da62de96 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 11 Mar 2015 09:10:47 -0400 Subject: [PATCH] Workaround for a problem in ICU library < 4.9 - Used to cause formatCurrency to fail if locale had comma as a decimal separator. --- .../src/VuFind/View/Helper/Root/SafeMoneyFormat.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormat.php b/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormat.php index 79b47112e2a..874cad99f48 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormat.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SafeMoneyFormat.php @@ -88,8 +88,15 @@ class SafeMoneyFormat extends AbstractHelper $currency = $this->defaultCurrency; } $escaper = $this->getView()->plugin('escapeHtml'); - return $escaper( + // Workaround for a problem in ICU library < 4.9 causing formatCurrency to + // fail if locale has comma as a decimal separator. + // (see https://bugs.php.net/bug.php?id=54538) + $locale = setlocale(LC_ALL, 0); + setlocale(LC_ALL, ['en_us.UTF-8', 'en_us.UTF8', 'en_us']); + $result = $escaper( $this->formatter->formatCurrency((float)$number, $currency) ); + setlocale(LC_ALL, $locale); + return $result; } } -- GitLab