Anything Intl always need to extract out
and memoized
This commit is contained in:
parent
d77ba19308
commit
708976a9e9
|
@ -1,10 +1,16 @@
|
||||||
export default function localeCode2Text(code) {
|
import mem from './mem';
|
||||||
try {
|
|
||||||
return new Intl.DisplayNames(navigator.languages, {
|
const IntlDN = new Intl.DisplayNames(navigator.languages, {
|
||||||
type: 'language',
|
type: 'language',
|
||||||
}).of(code);
|
});
|
||||||
|
|
||||||
|
function _localeCode2Text(code) {
|
||||||
|
try {
|
||||||
|
return IntlDN.of(code);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default mem(_localeCode2Text);
|
||||||
|
|
Loading…
Reference in a new issue