Translate Comments in WordPress

For one of the many projects of mine “Teacher in A Bottle” I have been looking for a plugin or way to translate comments on the fly. That is to say to automatically translate comments when a visitor wants to. Or way to get comments made translated into the language of the teacher. There are many translate plugins that add a widget to your site to for example use Google Translate to translate the whole page in language x, but what if you want to translate only the comments made on a page? Just because these were made in Russian and your native language is English?

Outdated Stuff

I quickly bumped into many plugins that were outdated such as “Translate This Button” , “Global Translator”  , Google AJAX Translations  and others. I also found many that just offer to install / load a translate widget as mentioned such as the Google Translate Plugin .

Comments Translation Only

As said I only wanted to get the conversation or comments translated. Google does have an app for this. Now I need integration with WordPress or if need be Disqus commments. I prefer not to integrate the site with Google Plus comments  as not everybody uses G+. The same goes for the Facebook Translate option out there  , which is abysmall anyways as it uses Bing Translate.

Disqus and Google Translate

Cloudpipes says they have an option to make Disqus work with Google Translate here but this is an invite only option and I did not see any demos.

Google Translate Plugin

One option would be to use the Google Translate Plugin  the way WordPress Beginner suggests here and then use the shortcode to wrap comments made perhaps. There is a Bing like plugin as well, but as said Bing isn’t great at translating as of yet. So the Google Translate option with template adjustments using the built in shortcode might be the best way to go.

Shortcode in Template

To actually use the shortcode

[google-translator]

to translate a part of the site I found out the shortcode was not made for this. It is just to load the translation widget in a different location. That it can be useful still I will explain below. To use shortcode in a template please see the WordPress Codex here. A snippet like:

<?php
echo do_shortcode('[google-translator]');
?>

will do the trick very nicely.

Exclude Site Content

This same Google Translate plugin also offerts the option to make certain parts of the site not translatable so you could make all NOT translateable, but the comments section. I quote from their FAQ “Add the “notranslate” class to the HTML element containing your text” This class you could add to all elements except for the one loading the comments and then add the translation button with the shortcode just above the comment section.

There we go, we made some progress 🙂 !

Featured Imagehttp://en.wikipedia.org/wiki/Tower_of_Babel

Tagged in : Tagged in : ,
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.