Move this up, Intl stuff seems to run slow sometimes
This commit is contained in:
parent
be964f933c
commit
8cd3e38f22
|
@ -3,6 +3,11 @@ import translationTargetLanguages from '../data/lingva-target-languages';
|
|||
import localeMatch from './locale-match';
|
||||
import states from './states';
|
||||
|
||||
const locales = [
|
||||
new Intl.DateTimeFormat().resolvedOptions().locale,
|
||||
...navigator.languages,
|
||||
];
|
||||
|
||||
function getTranslateTargetLanguage(fromSettings = false) {
|
||||
if (fromSettings) {
|
||||
const { contentTranslationTargetLanguage } = states.settings;
|
||||
|
@ -11,10 +16,7 @@ function getTranslateTargetLanguage(fromSettings = false) {
|
|||
}
|
||||
}
|
||||
return localeMatch(
|
||||
[
|
||||
new Intl.DateTimeFormat().resolvedOptions().locale,
|
||||
...navigator.languages,
|
||||
],
|
||||
locales,
|
||||
translationTargetLanguages.map((l) => l.code.replace('_', '-')), // The underscore will fail Intl.Locale inside `match`
|
||||
'en',
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue