Fix wrong passing of locale values in Intl.DisplayNames

pull/627/head
Lim Chee Aun 2024-08-14 09:41:31 +08:00
rodzic c31162220e
commit b28fdcb0fa
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -29,12 +29,15 @@ function _localeCode2Text(code) {
} catch (e) {
if (codeMappings[code]) {
try {
const text = IntlDN(locale || i18n.locale).of(codeMappings[code]);
const text = IntlDN(codeMappings[locale] || locale || i18n.locale).of(
codeMappings[code],
);
if (text !== codeMappings[code]) return text;
return fallback || '';
} catch (e) {}
} catch (e2) {
console.warn(code, e2);
}
}
console.warn(code, e);
return fallback || '';
}
}