From 28e50e07c4ac96f0d5071e2076b07cec9f746fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sof=C3=ADa=20Aritz?= Date: Wed, 10 May 2023 20:20:45 +0200 Subject: [PATCH] Improve language detection script --- static/assets/scripts/detectlang.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/assets/scripts/detectlang.js b/static/assets/scripts/detectlang.js index 46bc48c..322f729 100644 --- a/static/assets/scripts/detectlang.js +++ b/static/assets/scripts/detectlang.js @@ -7,11 +7,11 @@ if (redirect_notice_enabled()) { let language = (navigator.language || navigator.userLanguage).split("-")[0] if (location.pathname.startsWith("/en")) { 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") { - add_redirect_notice("/en" + location.pathname, ENGLISH_MESSAGE, ENGLISH_BUTTON) + add_redirect_notice("/en" + location.pathname.slice(0, -1), ENGLISH_MESSAGE, ENGLISH_BUTTON) } } }