Skip to content

Commit f281c44

Browse files
fix: load does not preserve number pattern spaces
1 parent b646017 commit f281c44

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/cldr/load-numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CURRENCY, ACCOUNTING, DECIMAL, CURRENCY_PLACEHOLDER, NUMBER_PLACEHOLDER
44
const LATIN_NUMBER_FORMATS = "Formats-numberSystem-latn";
55
const LATIN_NUMBER_SYMBOLS = "symbols-numberSystem-latn";
66

7-
const patternRegExp = /([ #,0. ]+)/g;
7+
const patternRegExp = /([#,0.]+)/g;
88
const cldrCurrencyRegExp = /¤/g;
99

1010
function getPatterns(pattern) {

test/cldr.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ describe('load numbers', () => {
6363
expect(percent.groupSize[0]).toEqual(3);
6464
});
6565

66+
it('preserve pattern spaces', () => {
67+
load({
68+
main: {
69+
patternSpaces: {
70+
numbers: {
71+
"decimalFormats-numberSystem-latn": {
72+
standard: "foo #,##0.### bar;bar #,##0.### foo "
73+
},
74+
"currencyFormats-numberSystem-latn":{
75+
standard: "¤ #,##0.00 bar",
76+
accounting: "foo #,##0.00 ¤",
77+
},
78+
"percentFormats-numberSystem-latn": {
79+
standard: "% #,##0.00 bar",
80+
}
81+
}
82+
}
83+
}
84+
});
85+
const info = cldr.patternSpaces.numbers;
86+
87+
expect(info.decimal.patterns[0]).toEqual("foo n bar");
88+
expect(info.decimal.patterns[1]).toEqual("bar n foo ");
89+
expect(info.currency.patterns[0]).toEqual("$ n bar");
90+
expect(info.accounting.patterns[0]).toEqual("foo n $");
91+
expect(info.percent.patterns[0]).toEqual("% n bar");
92+
});
93+
6694
describe('load currencies', () => {
6795

6896
it('should set currencies', () => {

0 commit comments

Comments
 (0)