More fallbacks for Intl.DisplayNames

This commit is contained in:
Lim Chee Aun 2024-08-16 11:14:16 +08:00
parent bdb1dff278
commit 6c0f0a4127

View file

@ -25,6 +25,10 @@ function _localeCode2Text(code) {
try { try {
const text = IntlDN(locale || i18n.locale).of(code); const text = IntlDN(locale || i18n.locale).of(code);
if (text !== code) return text; if (text !== code) return text;
if (!fallback) {
const anotherText = IntlDN(code).of(code);
if (anotherText !== code) return anotherText;
}
return fallback || ''; return fallback || '';
} catch (e) { } catch (e) {
if (codeMappings[code]) { if (codeMappings[code]) {