diff --git a/src/cldr/load-numbers.js b/src/cldr/load-numbers.js index a4d130d3..9a037b9c 100644 --- a/src/cldr/load-numbers.js +++ b/src/cldr/load-numbers.js @@ -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) { diff --git a/test/cldr.js b/test/cldr.js index a961dd81..260e332b 100644 --- a/test/cldr.js +++ b/test/cldr.js @@ -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', () => {