Skip to content

Commit d2286da

Browse files
authored
Symbol fallback (#129)
* fix(currency): symbol fallback * test(currency): add case for lang/locale pair without explicit symbol
1 parent 64db9ef commit d2286da

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/cldr/currency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function currencyDisplay(locale, options) {
112112
let result;
113113

114114
if (currencyDisplay === SYMBOL) {
115-
result = currencyInfo["symbol-alt-narrow"] || currencyInfo[SYMBOL];
115+
result = currencyInfo["symbol-alt-narrow"] || currencyInfo[SYMBOL] || currency;
116116
} else {
117117
if (typeof value === "undefined" || value !== 1) {
118118
result = currencyInfo["displayName-count-other"];

test/numbers.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const numbers = require("cldr-numbers-full/main/bg/numbers.json");
66
const currencies = require("cldr-numbers-full/main/bg/currencies.json");
77
const currencyData = require("cldr-core/supplemental/currencyData.json");
88

9-
load(likelySubtags, currencyData, numbers, currencies);
9+
const localNumbers = require("cldr-numbers-full/main/de-CH/numbers.json");
10+
const localCurrencies = require("cldr-numbers-full/main/de-CH/currencies.json");
11+
12+
load(likelySubtags, currencyData, numbers, currencies, localNumbers, localCurrencies);
1013

1114
function loadCustom(options) {
1215
load({
@@ -300,6 +303,10 @@ describe('standard currency formatting', () => {
300303
expect(formatNumber(10, "c", "bg-BG")).toEqual("10,00 лв.");
301304
});
302305

306+
it("should apply format when passing language and territory without symbol", () => {
307+
expect(formatNumber(10, "c", "de-CH")).toEqual("CHF 10.00");
308+
});
309+
303310
it("should apply format when passing object", () => {
304311
expect(formatNumber(10, { style: "currency" })).toEqual("$10.00");
305312
});

0 commit comments

Comments
 (0)