From b28fdcb0fa79b030cc976fb08b4e94fb2f2ea94e Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 14 Aug 2024 09:41:31 +0800 Subject: [PATCH] Fix wrong passing of locale values in Intl.DisplayNames --- src/utils/localeCode2Text.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/localeCode2Text.jsx b/src/utils/localeCode2Text.jsx index 84ffc424..d9a9bd21 100644 --- a/src/utils/localeCode2Text.jsx +++ b/src/utils/localeCode2Text.jsx @@ -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 || ''; } }