From 54e315a48fbe644637ebd0314b649cba408a53ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 5 May 2023 09:37:18 +0200 Subject: [PATCH] Fix WCF.String.formatNumeric() 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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 76539306ae..db26367362 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -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"); }, /** -- 2.20.1