Skip to content

Commit

Permalink
fix: load does not preserve number pattern spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkaradachki committed Nov 24, 2017
1 parent b646017 commit f281c44
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cldr/load-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CURRENCY, ACCOUNTING, DECIMAL, CURRENCY_PLACEHOLDER, NUMBER_PLACEHOLDER
const LATIN_NUMBER_FORMATS = "Formats-numberSystem-latn";
const LATIN_NUMBER_SYMBOLS = "symbols-numberSystem-latn";

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

function getPatterns(pattern) {
Expand Down
28 changes: 28 additions & 0 deletions test/cldr.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ describe('load numbers', () => {
expect(percent.groupSize[0]).toEqual(3);
});

it('preserve pattern spaces', () => {
load({
main: {
patternSpaces: {
numbers: {
"decimalFormats-numberSystem-latn": {
standard: "foo #,##0.### bar;bar #,##0.### foo "
},
"currencyFormats-numberSystem-latn":{
standard: "¤ #,##0.00 bar",
accounting: "foo #,##0.00 ¤",
},
"percentFormats-numberSystem-latn": {
standard: "% #,##0.00 bar",
}
}
}
}
});
const info = cldr.patternSpaces.numbers;

expect(info.decimal.patterns[0]).toEqual("foo n bar");
expect(info.decimal.patterns[1]).toEqual("bar n foo ");
expect(info.currency.patterns[0]).toEqual("$ n bar");
expect(info.accounting.patterns[0]).toEqual("foo n $");
expect(info.percent.patterns[0]).toEqual("% n bar");
});

describe('load currencies', () => {

it('should set currencies', () => {
Expand Down

0 comments on commit f281c44

Please sign in to comment.