I have a PHP website in three languages. I even have a changeLang (lang) function that perfectly changes the language from Portuguese to English or Spanish. However, the link on my page always stays the same, even when I change the language:
http://www.minhapagina.com/phase01?lang=pt-br
I would like the option to be able to change the language to English (eng) or Spanish (esp) when I change the link as well. I tried something like this at the top of the page phase01.php, but it did not work:
if(isset($_GET['lang'])){
if($_GET['lang'] == 'eng'){
echo "<script>window.addEventListener('DOMContentLoaded', function () { changeLang(1); }, false);</script>";
}
elseif($_GET['lang'] == 'esp'){
echo "<script>window.addEventListener('DOMContentLoaded', function () { changeLang(2); }, false);</script>";
}
else {
echo "<script>window.addEventListener('DOMContentLoaded', function () { changeLang(0); }, false);</script>";
}
}
What could I do?