Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
El cambio de idioma depende del navegador del usuario o del idioma del sistema operativo

Entonces, tengo dos páginas web, html y html_en.
¿Es posible detectar con el sistema JS o el idioma del navegador y, si no es italiano, cambiarlo automáticamente a la versión en inglés?
Sé que hay un navigator.language(s) para ayudarme, pero no sé cómo realizarlo juntos, para cambiar htmls si el idioma no lo es.
Gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bien, encontré una respuesta.
JS simple para eso.

 let language = window.navigator.language; let languageFistTwo = language.substr(0, 2); // To only keep the first 2 characters. let currentLocation = document .getElementsByTagName("html")[0] .getAttribute("lang-js"); switch (languageFistTwo) { case "it": if (currentLocation == "it") window.location.href = "../../index-test.html"; break; default: if (currentLocation != "en") { window.location.href = "../../index.html"; } }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!