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) {
|
||||
try {
|
||||
return new Intl.DisplayNames(navigator.languages, {
|
||||
import mem from './mem';
|
||||
|
||||
const IntlDN = new Intl.DisplayNames(navigator.languages, {
|
||||
type: 'language',
|
||||
}).of(code);
|
||||
});
|
||||
|
||||
function _localeCode2Text(code) {
|
||||
try {
|
||||
return IntlDN.of(code);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default mem(_localeCode2Text);
|
||||
|
|
Loading…
Reference in a new issue