<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> </head> <body> <script> //Language given in translation const langs = ['fr', 'en']; const defLang = 'en'; //Get the favorite language of the user's navigator const userLangs = (navigator.languages || [navigator.language]).map( a => a.split('-').shift(), ); userLangs.push(defLang); const selectedLang = userLangs.find(lang => langs.indexOf(lang) !== -1); //Redirection to the appropriate index.html document.location.replace(selectedLang); </script> </body> </html>