I have a website with three different languages place in separate folders as below.How am I able to change the en to cn if I click on the change cn language button?
www.example.com/en/content
www.example.com/cn/content
www.example.com/bn/content
<div class="language">
<a href="#/" id="EN" data-language="en">EN</a>
<a href="#/" id="CN" data-language="cn">CN</a>
<a href="#/" id="BN" data-language="bn">BN</a>
</div>
jquery
$(function changelang() {
$(".language a").click(function(e) {
var selectedLanguage = $(this).attr("data-language");
var currentContent = location.pathname.substring(
location.pathname.indexOf("/", 1) + 1,
location.pathname.length
);
// console.log(selectedLanguage, " >> ", currentContent);
window.location.href = "/" + selectedLanguage + "/" + currentContent;
});
});