I have a link that is used to switch languages in my site. When the user click on the link I want it to direct user to the chinese version of the page that is located inside the /ch/ folder.
For example, when user is on mysite/account/en/index.html, when click on the link, user should be redirected to mysite/account/ch/index.html
I tried the below code but it is not working. Anyone know a better code?
<li class="lang"><a id="langswitch" href="javascript: window.location.href.replace('/en/', '/ch/');" ><img src="/images/account/buttons/chinese.jpg" alt="chinese language" align="top" /></a></li>
I have a link that is used to switch languages in my site. When the user click on the link I want it to direct user to the chinese version of the page that is located inside the /ch/ folder.
For example, when user is on mysite./account/en/index.html, when click on the link, user should be redirected to mysite./account/ch/index.html
I tried the below code but it is not working. Anyone know a better code?
<li class="lang"><a id="langswitch" href="javascript: window.location.href.replace('/en/', '/ch/');" ><img src="/images/account/buttons/chinese.jpg" alt="chinese language" align="top" /></a></li>
Share
Improve this question
asked Feb 18, 2014 at 23:33
user3108698user3108698
7193 gold badges9 silver badges23 bronze badges
1
-
ch
usually refers to Switzerland; usezh
to refer to Chinese! see: en.wikipedia/wiki/IETF_language_tag and unicode/cldr/utility/languageid.jsp?a=zh&l=en – feeela Commented Feb 18, 2014 at 23:41
2 Answers
Reset to default 3I believe all that you are missing is
window.location = window.location.href.replace('/en/', '/ch/');
why cant you use
<li class="lang"><a id="langswitch" href="mysite./account/cn/index.html" ><img src="/images/account/buttons/chinese.jpg" alt="chinese language" align="top" /></a></li>