Improve language detection script
This commit is contained in:
parent
7d69d6d65e
commit
28e50e07c4
1 changed files with 3 additions and 3 deletions
|
@ -7,11 +7,11 @@ if (redirect_notice_enabled()) {
|
||||||
let language = (navigator.language || navigator.userLanguage).split("-")[0]
|
let language = (navigator.language || navigator.userLanguage).split("-")[0]
|
||||||
if (location.pathname.startsWith("/en")) {
|
if (location.pathname.startsWith("/en")) {
|
||||||
if (language === "es") {
|
if (language === "es") {
|
||||||
add_redirect_notice(location.pathname.replace("/en", ""), SPANISH_MESSAGE, SPANISH_BUTTON)
|
add_redirect_notice(location.pathname.replace("/en", "").slice(0, -1), SPANISH_MESSAGE, SPANISH_BUTTON)
|
||||||
}
|
}
|
||||||
} else if (!["weblog", "recommendations", "projects", "links"].includes(location.pathname.split("/")[1])) {
|
} else if (!["recommendations", "projects", "links"].includes(location.pathname.split("/")[1])) {
|
||||||
if (language !== "es") {
|
if (language !== "es") {
|
||||||
add_redirect_notice("/en" + location.pathname, ENGLISH_MESSAGE, ENGLISH_BUTTON)
|
add_redirect_notice("/en" + location.pathname.slice(0, -1), ENGLISH_MESSAGE, ENGLISH_BUTTON)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue