mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
fix issue where regional locales are not matched against our locales list (#12403)
* fix issue where regional locales are not matched against our locales list
This commit is contained in:
parent
83d5eec2dc
commit
22378e4f72
@ -38,9 +38,23 @@ export default async function getFirstPreferredLangCode() {
|
||||
userPreferredLocaleCodes = [];
|
||||
}
|
||||
|
||||
const firstPreferredLangCode = userPreferredLocaleCodes
|
||||
let firstPreferredLangCode = userPreferredLocaleCodes
|
||||
.map((code) => code.toLowerCase().replace('_', '-'))
|
||||
.find((code) => existingLocaleCodes[code] !== undefined);
|
||||
.find(
|
||||
(code) =>
|
||||
existingLocaleCodes[code] !== undefined ||
|
||||
existingLocaleCodes[code.split('-')[0]] !== undefined,
|
||||
);
|
||||
|
||||
// if we have matched against a code with a '-' present, meaning its a regional
|
||||
// code for which we have a non-regioned locale, we need to set firstPreferredLangCode
|
||||
// to the correct non-regional code.
|
||||
if (
|
||||
firstPreferredLangCode !== undefined &&
|
||||
existingLocaleCodes[firstPreferredLangCode] === undefined
|
||||
) {
|
||||
firstPreferredLangCode = firstPreferredLangCode.split('-')[0];
|
||||
}
|
||||
|
||||
return existingLocaleCodes[firstPreferredLangCode] || 'en';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user