Settings: Display browser language above other languages (#1106)
This commit is contained in:
parent
08cfbd9d25
commit
d2a10a5b8b
@ -64,11 +64,16 @@ const SettingsLanguage: FC<StateProps & DispatchProps> = ({
|
||||
};
|
||||
|
||||
function buildOptions(languages: ApiLanguage[]) {
|
||||
const currentLangCode = (window.navigator.language || 'en').toLowerCase();
|
||||
const shortLangCode = currentLangCode.substr(0, 2);
|
||||
|
||||
return languages.map(({ langCode, nativeName, name }) => ({
|
||||
value: langCode,
|
||||
label: nativeName,
|
||||
subLabel: name,
|
||||
}));
|
||||
})).sort((a) => {
|
||||
return currentLangCode && (a.value === currentLangCode || a.value === shortLangCode) ? -1 : 0;
|
||||
});
|
||||
}
|
||||
|
||||
export default memo(withGlobal(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user