Skip to content

Commit 3ddfaa4

Browse files
danielkaradachkitsvetomir
authored andcommitted
fix: default currency for global territories
1 parent c21e0ae commit 3ddfaa4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/cldr/currency.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const DEFAULT_CURRENCY_FRACTIONS = 2;
1515
const SYMBOL = "symbol";
1616
const INVALID_CURRENCY_CODE = 'XXX';
1717

18+
const GLOBAL_CURRENCIES = {
19+
'001': 'USD', // 001 refers to world. not sure if it is correct to assume USD but seems better than throw an error
20+
'150': 'EUR' // 150 territory for Europe
21+
22+
};
23+
1824
function getCurrencyInfo(locale, currency) {
1925
const info = getLocaleInfo(locale);
2026
const currencies = info.numbers.currencies;
@@ -121,6 +127,10 @@ export function currencyFractionOptions(code) {
121127
}
122128

123129
export function territoryCurrencyCode(territory) {
130+
if (GLOBAL_CURRENCIES[territory]) {
131+
return GLOBAL_CURRENCIES[territory];
132+
}
133+
124134
const currencyData = cldr.supplemental.currencyData;
125135
if (!currencyData) {
126136
throw NoSupplementalCurrency.error();

0 commit comments

Comments
 (0)