Skip to content

Commit 1beae74

Browse files
authored
Add missing number formats and currencies (#244)
* Add missing numbers formats and currencies * Fix failing number tests * Add tests for missung currencies
1 parent fcaf5d7 commit 1beae74

File tree

4 files changed

+89
-9
lines changed

4 files changed

+89
-9
lines changed

src/util/currency.js

+10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,26 @@ import { currencyToRegex } from './regex';
66

77
export const CURRENCY_FORMATS = {
88
EUR: {
9+
'el-CY': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
10+
'el-GR': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
11+
'et-EE': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
912
'de-AT': { prependSymbol: true, fractionalPrecision: 2, addSpace: true },
1013
'de-DE': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1114
'en-IE': { prependSymbol: true, fractionalPrecision: 2, addSpace: false },
15+
'en-MT': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1216
'es-ES': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
17+
'fi-FI': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1318
'fr-BE': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1419
'fr-FR': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
20+
'fr-LU': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1521
'it-IT': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
22+
'lt-LT': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
23+
'lv-LV': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1624
'nl-BE': { prependSymbol: true, fractionalPrecision: 2, addSpace: true },
1725
'nl-NL': { prependSymbol: true, fractionalPrecision: 2, addSpace: true },
1826
'pt-PT': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
27+
'sk-SK': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
28+
'sl-SI': { prependSymbol: false, fractionalPrecision: 2, addSpace: true },
1929
default: { prependSymbol: false, fractionalPrecision: 2, addSpace: true }
2030
},
2131
CHF: {

src/util/currency.spec.js

+57-7
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,36 @@ describe('currency', () => {
4141
testCurrency(inputs, 'EUR', 'nl-BE', outputsNl);
4242
});
4343

44-
it('should localize EUR for Germany', () => {
45-
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
46-
testCurrency(inputs, 'EUR', 'de-DE', outputs);
44+
it('should localize EUR for Cyprus', () => {
45+
const outputsFr = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
46+
testCurrency(inputs, 'EUR', 'el-CY', outputsFr);
4747
});
4848

49-
it('should localize EUR for Spain', () => {
50-
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
51-
testCurrency(inputs, 'EUR', 'es-ES', outputs);
49+
it('should localize EUR for Estonia', () => {
50+
const outputsFr = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
51+
testCurrency(inputs, 'EUR', 'et-EE', outputsFr);
52+
});
53+
54+
it('should localize EUR for Finland', () => {
55+
const outputsFr = ['11,23\xA0€', '1\x00000,00\xA0€', '0,98\xA0€'];
56+
testCurrency(inputs, 'EUR', 'fi-FI', outputsFr);
5257
});
5358

5459
it('should localize EUR for France', () => {
5560
const outputs = ['11,23\xA0€', '1\xA0000,00\xA0€', '0,98\xA0€'];
5661
testCurrency(inputs, 'EUR', 'fr-FR', outputs);
5762
});
5863

64+
it('should localize EUR for Germany', () => {
65+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
66+
testCurrency(inputs, 'EUR', 'de-DE', outputs);
67+
});
68+
69+
it('should localize EUR for Greece', () => {
70+
const outputsFr = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
71+
testCurrency(inputs, 'EUR', 'el-CY', outputsFr);
72+
});
73+
5974
it('should localize EUR for Ireland', () => {
6075
const outputs = ['€11.23', '€1,000.00', '€0.98'];
6176
testCurrency(inputs, 'EUR', 'en-IE', outputs);
@@ -66,6 +81,26 @@ describe('currency', () => {
6681
testCurrency(inputs, 'EUR', 'it-IT', outputs);
6782
});
6883

84+
it('should localize EUR for Latvia', () => {
85+
const outputs = ['11,23\xA0€', '1\x00000,00\xA0€', '0,98\xA0€'];
86+
testCurrency(inputs, 'EUR', 'lv-LV', outputs);
87+
});
88+
89+
it('should localize EUR for Lithuania', () => {
90+
const outputs = ['11,23\xA0€', '1\x00000,00\xA0€', '0,98\xA0€'];
91+
testCurrency(inputs, 'EUR', 'lv-LV', outputs);
92+
});
93+
94+
it('should localize EUR for Luxembourg', () => {
95+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
96+
testCurrency(inputs, 'EUR', 'fr-LU', outputs);
97+
});
98+
99+
it('should localize EUR for Malta', () => {
100+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
101+
testCurrency(inputs, 'EUR', 'en-MT', outputs);
102+
});
103+
69104
it('should localize EUR for Netherlands', () => {
70105
const outputs = ['€\xA011,23', '€\xA01.000,00', '€\xA00,98'];
71106
testCurrency(inputs, 'EUR', 'nl-NL', outputs);
@@ -76,6 +111,21 @@ describe('currency', () => {
76111
testCurrency(inputs, 'EUR', 'pt-PT', outputs);
77112
});
78113

114+
it('should localize EUR for Spain', () => {
115+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
116+
testCurrency(inputs, 'EUR', 'es-ES', outputs);
117+
});
118+
119+
it('should localize EUR for Slovakia', () => {
120+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
121+
testCurrency(inputs, 'EUR', 'sk-SK', outputs);
122+
});
123+
124+
it('should localize EUR for Slovenia', () => {
125+
const outputs = ['11,23\xA0€', '1.000,00\xA0€', '0,98\xA0€'];
126+
testCurrency(inputs, 'EUR', 'sl-SI', outputs);
127+
});
128+
79129
it('should localize CHF', () => {
80130
const outputsDe = ['CHF\xA011.23', "CHF\xA01'000.00", 'CHF\xA00.98'];
81131
testCurrency(inputs, 'CHF', 'de-CH', outputsDe);
@@ -133,7 +183,7 @@ describe('currency', () => {
133183
});
134184

135185
it('should localize DKK', () => {
136-
const outputs = ['11,23\xA0kr.', '1.000,00\xA0kr.', '0,98\xA0kr.'];
186+
const outputs = ['11,23\xA0kr.', '1\xA0000,00\xA0kr.', '0,98\xA0kr.'];
137187
testCurrency(inputs, 'DKK', 'da-DK', outputs);
138188
});
139189

src/util/numbers.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ import { get } from 'lodash';
33
export const NUMBER_SEPARATORS = {
44
'bg-BG': { decimal: ',', thousand: '\xA0' },
55
'cs-CZ': { decimal: ',', thousand: '\xA0' },
6-
'da-DK': { decimal: ',', thousand: '.' },
6+
'da-DK': { decimal: ',', thousand: '\xA0' },
77
'de-AT': { decimal: ',', thousand: '.' },
88
'de-CH': { decimal: '.', thousand: "'" },
99
'de-DE': { decimal: ',', thousand: '.' },
10+
'el-CY': { decimal: ',', thousand: '.' },
11+
'el-GR': { decimal: ',', thousand: '.' },
1012
'en-GB': { decimal: '.', thousand: ',' },
1113
'en-IE': { decimal: '.', thousand: ',' },
14+
'en-MT': { decimal: ',', thousand: '.' },
1215
'en-US': { decimal: '.', thousand: ',' },
1316
'es-CL': { decimal: ',', thousand: '.' },
1417
'es-ES': { decimal: ',', thousand: '.' },
18+
'et-EE': { decimal: ',', thousand: '.' },
19+
'fi-FI': { decimal: ',', thousand: '\0' },
1520
'fr-BE': { decimal: ',', thousand: '\xA0' },
1621
'fr-CH': { decimal: '.', thousand: '\xA0' },
1722
'fr-FR': { decimal: ',', thousand: '\xA0' },
23+
'fr-LU': { decimal: ',', thousand: '.' },
1824
'hr-HR': { decimal: ',', thousand: '.' },
1925
'hu-HU': { decimal: ',', thousand: '\xA0' },
2026
'it-CH': { decimal: ',', thousand: '.' },
2127
'it-IT': { decimal: ',', thousand: '.' },
28+
'lt-LT': { decimal: ',', thousand: '\0' },
29+
'lv-LV': { decimal: ',', thousand: '\0' },
2230
'nb-NO': { decimal: ',', thousand: '\xA0' },
2331
'nl-BE': { decimal: ',', thousand: '.' },
2432
'nl-NL': { decimal: ',', thousand: '.' },
@@ -28,6 +36,8 @@ export const NUMBER_SEPARATORS = {
2836
'pt-PT': { decimal: ',', thousand: '\xA0' },
2937
'ro-RO': { decimal: ',', thousand: '.' },
3038
'ru-RU': { decimal: ',', thousand: '\xA0' },
39+
'sl-SI': { decimal: ',', thousand: '.' },
40+
'sk-SK': { decimal: ',', thousand: '.' },
3141
'sv-SE': { decimal: ',', thousand: '\xA0' }
3242
};
3343

src/util/numbers.spec.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,30 @@ describe('numbers', () => {
6969
const expectedNumbers = {
7070
'bg-BG': '1\xA0000,00',
7171
'cs-CZ': '1\xA0000,00',
72-
'da-DK': '1.000,00',
72+
'da-DK': '1\xA0000,00',
7373
'de-AT': '1.000,00',
7474
'de-CH': "1'000.00",
7575
'de-DE': '1.000,00',
76+
'el-CY': '1.000,00',
77+
'el-GR': '1.000,00',
7678
'en-GB': '1,000.00',
7779
'en-IE': '1,000.00',
80+
'en-MT': '1.000,00',
7881
'en-US': '1,000.00',
7982
'es-CL': '1.000,00',
8083
'es-ES': '1.000,00',
84+
'et-EE': '1.000,00',
85+
'fi-FI': '1\x00000,00',
8186
'fr-BE': '1\xA0000,00',
8287
'fr-CH': '1\xA0000.00',
8388
'fr-FR': '1\xA0000,00',
89+
'fr-LU': '1.000,00',
8490
'hr-HR': '1.000,00',
8591
'hu-HU': '1\xA0000,00',
8692
'it-CH': '1.000,00',
8793
'it-IT': '1.000,00',
94+
'lt-LT': '1\x00000,00',
95+
'lv-LV': '1\x00000,00',
8896
'nb-NO': '1\xA0000,00',
8997
'nl-BE': '1.000,00',
9098
'nl-NL': '1.000,00',
@@ -94,6 +102,8 @@ describe('numbers', () => {
94102
'pt-PT': '1\xA0000,00',
95103
'ro-RO': '1.000,00',
96104
'ru-RU': '1\xA0000,00',
105+
'sl-SI': '1.000,00',
106+
'sk-SK': '1.000,00',
97107
'sv-SE': '1\xA0000,00'
98108
};
99109
locales.forEach(locale => {

0 commit comments

Comments
 (0)