I'm writing this website which has a navigation bar on top of the window on which there's a toggle list that you can choose language you use to view this website.
I managed to wrote the code for the language switching button and here's the code:
<li class="dropdown ' . (in_array($currentFile,$servicesArr)?'active':'') . '">
<a class="dropdown-toggle">
<img src="assets/images/flags/cn.png" width="16" height="11" alt="CN 語言" /> [CN] 简体中文<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="index.php">
<img src="assets/images/flags/hk.png" width="16" height="11" alt="CN 語言" /> [HK] 繁體中文</a>
</li>
<li><a href="#">
<img src="assets/images/flags/us.png" width="16" height="11" alt="EN Language" /> [US] English</a>
</li>
</ul>
</li>
So, my question is: according to my code, everytime I change a language, the link will take to the index of that language, but what if I'm not at the index page of my current language? Say, if I'm viewing index-en/job.php in English, now I want to switch to Chinese, instead of going to index-cn after click on the toggle button, I want to switch to index-cn/job.php. How can I do that?
Thanks in advance!
</div>