Skip to content

Commit b0d6f49

Browse files
committed
fix(localize): update the way to obtain the group separator for a number
four digit numbers can be written without separator, so it would be safer to obtain the separator by formatting a five digit number. The bug was found with the locale 'es-ES', where the format returned for '1000' was '1000' instead of the expected '1.000'. We add the specific expect clause on the test for it. On branch fix/numberGroupSeparator Changes to be committed: modified: packages/localize/src/number/getGroupSeparator.js modified: packages/localize/test/number/getGroupSeparator.test.js
1 parent 2bf8c07 commit b0d6f49

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/localize/src/number/getGroupSeparator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export function getGroupSeparator(locale) {
1212
const formattedNumber = Intl.NumberFormat(computedLocale, {
1313
style: 'decimal',
1414
minimumFractionDigits: 0,
15-
}).format('1000');
16-
return normalSpaces(formattedNumber[1]);
15+
}).format('10000');
16+
return normalSpaces(formattedNumber[2]);
1717
}

packages/localize/test/number/getGroupSeparator.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ describe('getGroupSeparator', () => {
77
expect(getGroupSeparator('en-GB')).to.equal(',');
88
expect(getGroupSeparator('nl-NL')).to.equal('.');
99
expect(getGroupSeparator('fr-FR')).to.equal(' ');
10+
expect(getGroupSeparator('es-ES')).to.equal('.');
1011
});
1112
});

0 commit comments

Comments
 (0)