diff --git a/src/utils/localeCode2Text.jsx b/src/utils/localeCode2Text.jsx index e9843ac..5c8ada7 100644 --- a/src/utils/localeCode2Text.jsx +++ b/src/utils/localeCode2Text.jsx @@ -1,10 +1,16 @@ -export default function localeCode2Text(code) { +import mem from './mem'; + +const IntlDN = new Intl.DisplayNames(navigator.languages, { + type: 'language', +}); + +function _localeCode2Text(code) { try { - return new Intl.DisplayNames(navigator.languages, { - type: 'language', - }).of(code); + return IntlDN.of(code); } catch (e) { console.error(e); return null; } } + +export default mem(_localeCode2Text);