XF 2.2 Function languageFormat / currencyFormat

topkurs2

Active member
Hello.
Function languageFormat returns fixed decimal count by default. I have function, that formats this value and changes into custom view. To 0.123 fa-icon. It worked fine till late XF 2.1.x versions. Than in last versions seems something changes and this function stopped work correctly.

Code:
    public static function formatValue($billId, $value, $useFa = true)
    {
        $app = \XF::app();
        $language = \XF::language();

        $bills = $app['abills'];
        $currencySymbol = self::getCurrencySymbol($bills[$billId], $useFa);

        $number = number_format($value, 3, '.', '');
        if (strpos($number, '.') !== false) {
            $number = rtrim($number, '0');
        }

        [$whole, $decimal] = explode('.', $number);

        return $language->currencyFormat($value, $currencySymbol, strlen($decimal));
    }
I would be grateful if you tell me where the error is. Or will help to rewrite the function correctly.
 
For unknown reasons, the XF\Language::currencyFormat method now returns two decimal places despite the argument passed. I think this is a bug. Although there are currencies in XF\Data\Currency that have greater precision, this value will be ignored.

Maybe @Chris D can explain the reason why it was decided to do so.
 
For unknown reasons, the XF\Language::currencyFormat method now returns two decimal places despite the argument passed. I think this is a bug. Although there are currencies in XF\Data\Currency that have greater precision, this value will be ignored.

Maybe @Chris D can explain the reason why it was decided to do so.
Yes, unfortunately I also experienced. But I thought the function was replaced or something like that. I don't follow XF development in detail.
Although there are currencies in XF\Data\Currency that have greater precision, this value will be ignored.
+1

I think this is a bug.
Maybe we should move this thread to https://xenforo.com/community/forums/bugs/? I looked there, there is no such ticket.
 
Top Bottom