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?
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
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 Image: http://en.wikipedia.org/wiki/Tower_of_Babel
Hi Jasper been looking for this for ages, I have launched my site in 2 countries, and couldn+t get how to translate comments from people to my products, I use polylang for the site itself but as for comments would like exactly what you put here. Just have a question, I use Woocomerce for my products, so I don´t have exactly a product for each page unless I create that product, how can I put the shortcode in order to when I create a new product the option to translate future comments will appear already! Thank you very much. Cheers
A template change will be needed Jorge.That way you can load the translation tool in a location where the comments are added. Normally it is only available where the plugin is able to add the widget. Let me know if you need further help with this.
Hi Jasper thanks for the input, surely it worked partially, I added the shortcode directly to the comments plugin, but still it is translating the whole page, the difference is like you mentioned, it changes the position where the “flags” appear. Do I need to add in the functions.php to not translate and clearly define there what widgets should not be translated? Is this an option? Nevertheless great review, helped me in the translations so far!So half way there 🙂
Sorry for the late reply here Jorge. Many things going on at the moment.Did you ever use the notranslate class to skip translating certain html elements?
Forgot to add something, because we have 2 views and this potentially works, if wording is correct for both languages, let´s say Dutch and English.
I use Dutch site and there are comments in english, so I want to translate to Dutch, so I use the google translator, but the site translation was made by Polylang, so I guess if the google tries to translate everything it will only deliver the same Dutch wording he has there.
Same principle applies to English and translating dutch comments.
This can be a start but involves more effort in “supposably” translating everything. Of course ideally would be only translating comments.