I need to make a language switch and make it able to go to the respective translated page. The link of that switch is given an id “ext-trans”:
<a id="ext-trans" href="#" > LINK </a>
Is there a way to detect the current browser’s URL, such as:
( no matter the current URL is /en/ or /tc/ or /sc/, just need /tc/ in result )
( xxxxx is the remaining path )
<script> $('#ext-trans').attr('href', 'https://translate.itsc.cuhk.edu.hk/uniTS/' + window.location.hostname + '/tc' + window.location.pathname.substr(3)) </script>
It would be so great if anyone would know how to do it.
Thanks a lot in advance!