0

How would I approach automatically applying a Google translation to page content for ~500 custom posts on my site?

I’ve created a French version of my website using the WPML plugin (French site here). My issue is that every post on this French site still has all page content in English, not French. As you can see in this example post–the menus, footer, etc are in French, but the content is still in English (e.g. “A spacious 3 bedroom villa located…”). Is there a way to ensure this content is automatically translated to another language, using Google Translate?? In other words, when a visitor opens this page, the content in-question would automatically be translated to French, via Google Translate.

I realize that, using the WPML plugin, I can add translations to each of these posts–one by one–via the WordPress editor. And indeed, that’s the entire purpose of using WPML. But I have ~500 of these custom posts. I am working on manual translations for each. But in the meantime, I was hoping to add automatic machine translations, if possible.

There are plugins that do something similar. But I believe they all attempt to translate the entire page, including menus, footer, etc. This is undesirable, since I already have manual translations of those. Plus, I’m not sure if any automatically apply a particular translation. I would like a solution that automatically translates page content only. Additionally, none of those plugins are compatible with WPML (I’ve confirmed that with WPML support). Using both together introduces issues. In fact, I already use one such plugin, and had to deal with issues from using both together.

Thanks.

  • Take a look on this Xonox processwire.com/talk/topic/… . Seems to work like you want and it will need very small adjustment to incorporate only the content to be translated. For example you can even use the class="notranslate" (cloud.google.com/translate/faq#technical_questions) or googleAutoTranslate($page, 'body'); – Drupalizeme Oct 31 '17 at 13:18
  • @Drupalizeme would that solution require me to migrate my entire site from WordPress to ProcessWire? Or could I perhaps modify that code to work with my WP site? Or is that code even platform-independent? Regardless, I think perhaps the overarching answer is to write my own custom code using the Google Translation API, agreed? – cag8f Oct 31 '17 at 17:18
  • The provided link showing how you can make the use of the API to translate the content you want. You don't need to migrate to processwire. The general idea is the same. Use a loop to loop the content and provide the call to translate the content. – Drupalizeme Oct 31 '17 at 19:49
  • OK thanks for that. I'll need a some time to test this. Plus, I may opt to forego such translation. Either way, it's good to know something like this exists. – cag8f Nov 1 '17 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.