Fix slow code blocking whole component render

pull/375/head
Lim Chee Aun 2023-12-28 18:39:56 +08:00
rodzic 1765defa56
commit 88547fa403
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -8,6 +8,12 @@ const locales = [
...navigator.languages,
];
const localeTargetLanguages = localeMatch(
locales,
translationTargetLanguages.map((l) => l.code.replace('_', '-')), // The underscore will fail Intl.Locale inside `match`
'en',
);
function getTranslateTargetLanguage(fromSettings = false) {
if (fromSettings) {
const { contentTranslationTargetLanguage } = states.settings;
@ -15,11 +21,7 @@ function getTranslateTargetLanguage(fromSettings = false) {
return contentTranslationTargetLanguage;
}
}
return localeMatch(
locales,
translationTargetLanguages.map((l) => l.code.replace('_', '-')), // The underscore will fail Intl.Locale inside `match`
'en',
);
return localeTargetLanguages;
}
export default getTranslateTargetLanguage;