mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
feat(i18n): ca-valencia
language detection in Edge browser (#1828)
This commit is contained in:
parent
2ccec5e09c
commit
baba3faa34
1 changed files with 12 additions and 5 deletions
|
@ -2,12 +2,19 @@ export function matchLanguages(languages: string[], acceptLanguages: readonly st
|
||||||
{
|
{
|
||||||
// const lang = acceptLanguages.map(userLang => languages.find(lang => lang.startsWith(userLang))).filter(v => !!v)[0]
|
// const lang = acceptLanguages.map(userLang => languages.find(lang => lang.startsWith(userLang))).filter(v => !!v)[0]
|
||||||
// TODO: Support es-419, remove this code if we include spanish country variants
|
// TODO: Support es-419, remove this code if we include spanish country variants
|
||||||
const lang = acceptLanguages.map(userLang => languages.find((lang) => {
|
const lang = acceptLanguages.map(userLang => languages.find((currentLang) => {
|
||||||
if (userLang.startsWith('es-') && userLang !== 'es-ES')
|
if (currentLang === userLang)
|
||||||
return lang === 'es-419'
|
return currentLang
|
||||||
|
|
||||||
return lang.startsWith(userLang)
|
// Edge browser: case for ca-valencia
|
||||||
})).filter(v => !!v)[0]
|
if (currentLang === 'ca-valencia' && userLang === 'ca-Es-VALENCIA')
|
||||||
|
return currentLang
|
||||||
|
|
||||||
|
if (userLang.startsWith('es-') && userLang !== 'es-ES' && currentLang === 'es-419')
|
||||||
|
return currentLang
|
||||||
|
|
||||||
|
return currentLang.startsWith(userLang) ? currentLang : undefined
|
||||||
|
})).filter(v => !!v)?.[0]
|
||||||
if (lang)
|
if (lang)
|
||||||
return lang
|
return lang
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue