I have been using Angsuman’s Translator Plugin Pro to provide language translations on numerous WordPress blogs for a long time. Recently I noticed that when visiting translated pages the links contained within those translated pages were linking back to the default language which in my case is English. This makes trying to navigate through the site in a different language much more of a hassle.
Translated Page Links Issue:
To explain a little further I will provide some examples. I currently provide flags to translate the site in thirteen languages not including English. If you click on a flag it will translate the page to that flags default language such as Spanish for instance. Below are a couple examples of links and how they should act when viewing translated pages.
The Default QD Link:
- <a href="http://www.question-defense.com/">http://www.question-defense.com/</a>
Same Link Translated To Spanish:
- <a href="http://www.question-defense.com/es/">http://www.question-defense.com/es/</a>
So when on the default English page and you hover links they would all show similar to the below.
Links Shown From English Homepage Example Above:
- <a href="http://www.question-defense.com/contact">http://www.question-defense.com/contact</a>
- <a href="http://www.question-defense.com/2009/11/14/windows-xp-turn-off-auto-play-for-external-usb-hard-drive/">http://www.question-defense.com/2009/11/14/windows-xp-turn-off-auto-play-for-external-usb-hard-drive/</a>
- <a href="http://question-defense.com/tags">http://question-defense.com/tags</a>
When on the Spanish translated home page and you hover links they should show similar to the below.
Links Shown From Spanish Homepage Example Above:
- <a href="http://www.question-defense.com/contact/es/">http://www.question-defense.com/contact/es/</a>
- <a href="http://www.question-defense.com/2009/11/14/windows-xp-turn-off-auto-play-for-external-usb-hard-drive/es/">http://www.question-defense.com/2009/11/14/windows-xp-turn-off-auto-play-for-external-usb-hard-drive/es/</a>
- <a href="http://question-defense.com/tags/es/">http://question-defense.com/tags/es/</a>
This way when you are navigating the site in a translated language such as Spanish each page you visit would continue to be translated in Spanish. What I was noticing though is every link on a translated page was sending you to the English version instead of the Spanish version or /it/ of that link. In the Translator Plugin Pro I was using the Google Translation Engine, URL for Translation Method, and Pre Process each URL. I was unable to find a combination of settings that would work how I wanted with Google so I started trying other Translation Engines. After trying all sorts of different combinations I noticed that using the BabelFish Translation Engine ended up working best for me using the below settings for each specific language I translate to.
Translation Method: URL
Data Processing:Pre Process URL [YES]
When using the above settings for each language things functioned as I had hoped. If you clicked on the Spanish flag you were sent to the same URL with /es/ on the end of the URL to provide the Spanish translation. Next when you visited links from the translated pages they would continue to have /es/ attached to the end of the URL thus allowing you to navigate the site in Spanish. If you wanted to go back to English you simply remove the /it/ from the URL or you could click the US flag and that would send you back to the default English page as well.