Nf_lang redirects not working

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!

Language based redirection is not recommended as it doesn’t always work. This is one thread for example: Language redirection not working on Chrome and Firefox (working on Safari)

There are many such threads.