Settings: Display browser language above other languages (#1106)

This commit is contained in:
Alexander Zinchuk 2021-05-21 14:44:23 +03:00
parent 08cfbd9d25
commit d2a10a5b8b

View File

@ -64,11 +64,16 @@ const SettingsLanguage: FC<StateProps & DispatchProps> = ({
}; };
function buildOptions(languages: ApiLanguage[]) { function buildOptions(languages: ApiLanguage[]) {
const currentLangCode = (window.navigator.language || 'en').toLowerCase();
const shortLangCode = currentLangCode.substr(0, 2);
return languages.map(({ langCode, nativeName, name }) => ({ return languages.map(({ langCode, nativeName, name }) => ({
value: langCode, value: langCode,
label: nativeName, label: nativeName,
subLabel: name, subLabel: name,
})); })).sort((a) => {
return currentLangCode && (a.value === currentLangCode || a.value === shortLangCode) ? -1 : 0;
});
} }
export default memo(withGlobal( export default memo(withGlobal(