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

80
Views
Language Switcher - How to change link and make dynamic

I'm trying to create a language switcher to change between two languages Nederlands/English

I need the link to be changed whenever I'm on a page, like this

www.example.nl/page/lorem to www.example.nl/en/page/lorem

www.example.nl/en/page/lorem to www.example.nl/page/lorem

NOT

www.example.nl/page/lorem to www.example.nl/en/

www.example.nl/en/page/lorem to www.example.nl/

This is the code I'm using, but it doesn't work:

$(document).ready(function() {
    var winLocation = window.location;
    var loc = winLocation + "";
    if(loc.indexOf("/manasik_nl/en") != -1) {
       $(".lang").prop("href", loc.replace("/manasik_nl/en", "/manasik_nl/"));
       $(".lang").text("Nederlands");
    }
    else if(loc.indexOf("/manasik_nl/") != -1) {
       $(".lang").prop("href", loc.replace("/manasik_nl/", "/manasik_nl/en"));
       $(".lang").text("English");
    }
});
<div class="language-switcher">
<a class="lang" href="/manasik_nl/" language="English"><img class="alignnone size-full wp-image-110" src="https://manasik.nl/manasik_nl/wp-content/uploads/2022/03/nl.png" alt="" width="18" height="12" /></a>
<a class="lang" href="/manasik_nl/en/" language="Nederlands"><img class="alignnone size-full wp-image-109" src="https://manasik.nl/manasik_nl/wp-content/uploads/2022/03/en.png"  alt="" width="18" height="12" /></a></div>

I would appreciate it if anyone could help, thanks.

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

0

Just run this html code example:

<select id="languages">
      <option id='1' value="English" placeholder='English'>
      <option id='2' value="Nederlands" placeholder='Nederlands'>
</select>

And add some JavaScript onclick function that switch from a page to another one with window.location.

document.getElementByID('1').onclick = function(){
      window.location.assign("your URL")
};
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!