diff --git a/framework/core/js/src/common/utils/formatNumber.ts b/framework/core/js/src/common/utils/formatNumber.ts index 436a8131c..0e1f1284b 100644 --- a/framework/core/js/src/common/utils/formatNumber.ts +++ b/framework/core/js/src/common/utils/formatNumber.ts @@ -1,11 +1,13 @@ +import app from '../../forum/app'; + /** * The `formatNumber` utility localizes a number into a string with the - * appropriate punctuation. + * appropriate punctuation based on the provided locale otherwise will default to the users locale. * * @example * formatNumber(1234); * // 1,234 */ -export default function formatNumber(number: number): string { - return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +export default function formatNumber(number: number, locale: string = app.data.locale): string { + return new Intl.NumberFormat(locale).format(number); }