fix(localize): use option.locale to get separator in formatNumberToParts
This commit is contained in:
parent
169f0ef97e
commit
093cfa090a
2 changed files with 4 additions and 4 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue