Fix "lang" selector in url

location.search.match(/lang=([a-z]+)/) does return `['lang=fr', 'fr']` if it does match and thus does not found the language with the query parameter.

This commit fixes this comportment
This commit is contained in:
Julien Deniau 2020-02-06 10:08:50 +01:00 committed by GitHub
parent 89d45ef14f
commit 5a21c4d7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,7 +286,8 @@
} }
function trans(key) { function trans(key) {
const queryLang = location.search.match(/lang=([a-z]+)/); var matchLang = location.search.match(/lang=([a-z]+)/);
var queryLang = matchLang ? matchLang[1] : null;
var locale = queryLang || navigator.language || navigator.userLanguage; var locale = queryLang || navigator.language || navigator.userLanguage;
var translations = getTranslations(); var translations = getTranslations();