Hello!
I am trying to redirect the user to the correct language based on the cookie nf_lang.
I am using a language modal with javascript code to set the cookie:
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script>
$(".lang-select").click(function () {
console.log("nf_lang="+$(this).attr("lang"));
Cookies.set('nf_lang', $(this).attr("lang"), { expires: 365 });
});
if (Cookies.get('nf_lang') == null) {
$("#language").modal();
}
</script>
I have the following redirect in my netlify.toml
[[redirects]]
from = "/"
to = "/en/"
force = true
status = 302
conditions = {Language = ["en"]}
[[redirects]]
from = "/"
to = "/es/"
force = true
status = 302
conditions = {Language = ["es"]}
[[redirects]]
from = "/"
to = "/eu/"
force = true
status = 302
conditions = {Language = ["eu"]}
But even if the javascript code is executed, the next time I go to the root path / it will redirect me to the english version.
The website is this one: https://aldapan.com and it is implemented with hugo
Thanks!