Skip to content
Snippets Groups Projects
index.html 1.28 KiB
Newer Older
Clément's avatar
Clément committed
<!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" />
    <script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=default,Array.prototype.includes,Array.prototype.find"></script>
Clément's avatar
Clément committed
  </head>
  <body>
    <script>
      if ((window.navigator.userAgent.indexOf("MSIE ") > -1 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) ||
        window.navigator.userAgent.indexOf("Edge/") > -1) {
        alert("Please either update your Edge browser to the last version (>= 80, you can check that in ... -> Settings -> General) or switch to another browser (Chrome / Safari / Firefox)");
      }
Alice Poggioli's avatar
Alice Poggioli committed
      //Language given in translation
      const langs = ['fr', 'en', 'it'];
Clément's avatar
Clément committed
      const defLang = 'en';
Alice Poggioli's avatar
Alice Poggioli committed

      //Get the favorite language of the user's navigator
Clément's avatar
Clément committed
      const userLangs = (navigator.languages || [navigator.language]).map(
        function (a) { return a.split('-').shift() }
Clément's avatar
Clément committed
      );
Clément's avatar
Clément committed
      userLangs.push(defLang);
      const selectedLang = userLangs.find(function(lang) { return langs.indexOf(lang) !== -1 });
Alice Poggioli's avatar
Alice Poggioli committed

      //Redirection to the appropriate index.html
Clément's avatar
Clément committed
      document.location.replace(selectedLang);
    </script>
  </body>
</html>