Multilingual : Detect browser language

So, I added a cookie like this :

// Create cookie to get the Browser Language
const userLang = navigator.language || navigator.userLanguage;
document.cookie = `nf_lang = ${userLang}`;

& I just rewrite these redirects and it seems to work (‘language = fr’ alone doesn’t work) !

# Redirect users with french language preference from / to /fr
/  /fr/  302  Language=fr
/  /fr/  302  Language=fr-be
/  /fr/  302  Language=fr-ca
/  /fr/  302  Language=fr-ch
/  /fr/  302  Language=fr-fr
/  /fr/  302  Language=fr-lu
/  /fr/  302  Language=fr-mc
  1. The only problem is when I click on “Pardon my french” to go to the english version, it redirects to the French version logically. So I can’t access the other language anymore.
    How would you fix this?

  2. Also, I couldn’t load the images & css at first because all URLs were re-written with /fr/.
    I had to change it but it’s not perfect. How would you do ?

/*  /fr/:splat  302  Language=fr # Was re-writing all assets with /fr/
/  /fr/  302  Language=fr # work only with the homepage

I have only one page now, but might have several pages later.
How would you use the * & :splat without affecting the assets so they can load properly ?

Thanks for your help!
Vianney.