diff --git a/packages/localize/src/number/formatNumberToParts.js b/packages/localize/src/number/formatNumberToParts.js index 7f01c5816..bff073212 100644 --- a/packages/localize/src/number/formatNumberToParts.js +++ b/packages/localize/src/number/formatNumberToParts.js @@ -61,7 +61,7 @@ export function formatNumberToParts(number, options) { formattedParts.push({ type: 'integer', value: numberPart }); numberPart = ''; } - const decimal = getDecimalSeparator(); + const decimal = getDecimalSeparator(computedLocale); if (formattedNumber[i] === decimal) { formattedParts.push({ type: 'decimal', value: formattedNumber[i] }); fraction = true; @@ -71,7 +71,7 @@ export function formatNumberToParts(number, options) { } // detect literals (empty spaces) or space group separator if (regexSpace.test(formattedNumber[i])) { - const group = getGroupSeparator(); + const group = getGroupSeparator(computedLocale); const hasNumberPart = !!numberPart; // Write number grouping if (numberPart && !fraction) { diff --git a/packages/localize/test/number/formatNumberToParts.test.js b/packages/localize/test/number/formatNumberToParts.test.js index d3aa21a42..4fcc45c2e 100644 --- a/packages/localize/test/number/formatNumberToParts.test.js +++ b/packages/localize/test/number/formatNumberToParts.test.js @@ -33,9 +33,9 @@ describe('formatNumberToParts', () => { specs.forEach(([locale, currency, amount, expectedResult]) => { it(`formats ${locale} ${currency} ${amount} as "${stringifyParts(expectedResult)}"`, () => { - localize.locale = locale; expect( formatNumberToParts(amount, { + locale, style: 'currency', currency, }), @@ -60,9 +60,9 @@ describe('formatNumberToParts', () => { specs.forEach(([locale, currency, amount, expectedResult]) => { it(`formats ${locale} ${currency} ${amount} as "${stringifyParts(expectedResult)}"`, () => { - localize.locale = locale; expect( formatNumberToParts(amount, { + locale, style: 'currency', currencyDisplay: 'code', currency,