Skip to content

Commit 093cfa0

Browse files
fix(localize): use option.locale to get separator in formatNumberToParts
1 parent 169f0ef commit 093cfa0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/localize/src/number/formatNumberToParts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function formatNumberToParts(number, options) {
6161
formattedParts.push({ type: 'integer', value: numberPart });
6262
numberPart = '';
6363
}
64-
const decimal = getDecimalSeparator();
64+
const decimal = getDecimalSeparator(computedLocale);
6565
if (formattedNumber[i] === decimal) {
6666
formattedParts.push({ type: 'decimal', value: formattedNumber[i] });
6767
fraction = true;
@@ -71,7 +71,7 @@ export function formatNumberToParts(number, options) {
7171
}
7272
// detect literals (empty spaces) or space group separator
7373
if (regexSpace.test(formattedNumber[i])) {
74-
const group = getGroupSeparator();
74+
const group = getGroupSeparator(computedLocale);
7575
const hasNumberPart = !!numberPart;
7676
// Write number grouping
7777
if (numberPart && !fraction) {

packages/localize/test/number/formatNumberToParts.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ describe('formatNumberToParts', () => {
3333

3434
specs.forEach(([locale, currency, amount, expectedResult]) => {
3535
it(`formats ${locale} ${currency} ${amount} as "${stringifyParts(expectedResult)}"`, () => {
36-
localize.locale = locale;
3736
expect(
3837
formatNumberToParts(amount, {
38+
locale,
3939
style: 'currency',
4040
currency,
4141
}),
@@ -60,9 +60,9 @@ describe('formatNumberToParts', () => {
6060

6161
specs.forEach(([locale, currency, amount, expectedResult]) => {
6262
it(`formats ${locale} ${currency} ${amount} as "${stringifyParts(expectedResult)}"`, () => {
63-
localize.locale = locale;
6463
expect(
6564
formatNumberToParts(amount, {
65+
locale,
6666
style: 'currency',
6767
currencyDisplay: 'code',
6868
currency,

0 commit comments

Comments
 (0)