Fix WCF.String.formatNumeric()
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 5 May 2023 07:37:18 +0000 (09:37 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 5 May 2023 07:37:18 +0000 (09:37 +0200)
The previously used phrase is no longer available to the JavaScript. It would
also be inconsistent. Copy the implementation of StringUtil#fornatNumeric

see 3a0d55353fe88c7510d7b973e1436bd430bcff46
Fixes #5471

wcfsetup/install/files/js/WCF.js

index 76539306aecfdacd530ac6ae996521f55f26cf28..db263673623fffe0c24e81a1be1d94eeb3748bb7 100755 (executable)
@@ -1967,15 +1967,13 @@ WCF.String = {
         * @return      string
         */
        formatNumeric: function(number, decimalPlaces) {
-               number = String(WCF.Number.round(number, decimalPlaces || 2));
-               var numberParts = number.split('.');
-               
-               number = this.addThousandsSeparator(numberParts[0]);
-               if (numberParts.length > 1) number += WCF.Language.get('wcf.global.decimalPoint') + numberParts[1];
-               
-               number = number.replace('-', '\u2212');
-               
-               return number;
+               var maximumFractionDigits = decimalPlaces || 2;
+
+               return Number(number)
+                       .toLocaleString(document.documentElement.lang, {
+                               maximumFractionDigits,
+                       })
+                       .replace("-", "\u2212");
        },
        
        /**