Book Sale! Code WP2025 takes 20% OFF our Pro Plugins & Books »
Web Dev + WordPress + Security

Valid, SEO-Friendly Post Translation Links

Ever wanted to provide automatic language translations of your web pages without installing another plugin? Here is a valid, SEO-friendly technique that takes advantage of Google’s free translation service. All you need is a PHP-enabled server and you’re good to go. Just copy and paste the following code into the desired location in your page template and enjoy the results. Once in place, this code will produce translation links for eight common languages for every page on your site. Grab, gulp and go:

<ul id="translations">
	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cde" rel="nofollow">Translate this page to Deutsch</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Ces" rel="nofollow">Translate this page to Espanol</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cfr" rel="nofollow">Translate this page to Francais</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cit" rel="nofollow">Translate this page to Italiano</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cpt" rel="nofollow">Translate this page to Portugues</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Car" rel="nofollow">Translate this page to Arabic</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cja" rel="nofollow">Translate this page to Japanese</a></li>

	<li><a href="http://translate.google.com/translate?u=<?php echo urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>&langpair=en%7Cko" rel="nofollow">Translate this page to Korean</a></li>
</ul>

As formatted, this code will generate an unordered list of translation links. You may change this formatting or even style the links with their associated country flags using a little CSS. When used on blogs, this code will enable users to translate posts on the fly via automatic generation of the required URL parameter. Further, each page URL is encoded within the query string to ensure complete markup validation. Finally, this code even goes the extra mile by including nofollow attributes in each link, thereby preventing valuable link juice from needlessly leaking to the Google translation machine.

About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.
BBQ Pro: The fastest firewall to protect your WordPress.
Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
GA Pro: Add Google Analytics to WordPress like a pro.
Thoughts
Launching my new plugin, Head Meta Pro 🚀 Complete meta tags for WordPress.
Migrating sites to a new server, so far so good. Please report any bugs, thank you.
Arc browser looked good but lost me at “account required”. No browsers do that.
Finishing up the pro version of Head Meta Data plugin, launch planned this month.
Finally finished my ultimate block list to stop AI bots :) Blocks over 400+ AI bots!
After 10 years working late at night, my schedule has changed. I am now a “morning person”, starting my day at 6am or earlier.
Nice update for Wutsearch search engine launchpad. Now with 19 engines including Luxxle AI-powered search.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.