I am using the Transposh WordPress plugin to make a site bilingual.
The plugin comes with a dropdown language selector, but I would like to instead place a link in the navigation that toggles the site between the two languages.
The default site is in English, and an example page might be xxx.com/page
The other language is Portuguese, with the translated page at xxx.com/pt/page
So I would like the link to toggle between these two values:
<a href="example.com/pt/page">Português</a>
and
<a href="example.com/page">English</a>
Would jQuery be best to do this?
Thanks in advance!
When you load your page with this “example.com/pt/page” link, change the href and text of the link to English. And when you load the page with “example.com/page”, change the href and text to Português.
Update:
If you want to add this link to all pages to your site, then:
1) set class for all the links. Like this:
2) Now modify the jQuery handler like this :
Assuming, your Português pages comes under “example.com/pt/” urls and English pages comes under “example.com/”
Since I wrote that plugin (Transposh) I think that your best way would be to write a simple widget to do as you wish, this will probably be a single line of code. Properly run at your backend, and do as you wished.
The guide is here:
http://trac.transposh.org/wiki/WidgetWritingGuide
You can check the is_active of the structure sent there to provide what you wanted.
Have fun