Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Replace last folder name in a URL for language switch

I'm looking for a simple method to switch a static multilingual website. The files have the same name in all languages, but are in different folders that are named with the language code (en, fr, es, de, ...).

Example:

mydomain.com/showcase/en/index.html
mydomain.com/showcase/fr/index.html

Now the visitor should be able to choose a different language with a language switcher. Which languages are available should remain open.

So the code has to jump from the end of the URL to the last / and then replace the previous two characters (no matter what it is, position -1 and -2 before the /) with the new language code. The language code will always be 2 digits and the language subdirectories are always at the end of the URL.

How do I get the new language code from the visitor's click? And how do I install it in the right place? How do I call the script in my html template?

Unfortunately, I'm a total beginner with js. I only know a little bit about html and css. I would be glad of a good code and an explanation of what it does exactly. I have found some partial solutions here, but none does exactly what I need.

thank you!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda