vitch
vitch

Reputation: 3214

Google's website translator and content loaded via AJAX

I am using Google's website translator on a website I am developing. In one section of the website I use AJAX to load new content into the page. I was hoping that there was a way to tell the Google translator to re-translate the loaded content (I could provide a DOM element that the content resides in).

I can't find any documentation which suggests how to do this and it appears that the Google Translate API is becoming a paid service. Is it possible to use the Google translator in the way I require or do you need to use the paid service?

Upvotes: 2

Views: 2775

Answers (1)

beeglebug
beeglebug

Reputation: 3542

You can call a function to re-translate the page in the same place you render the ajax content:

$.getScript("//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");

Here's an example on jsFiddle http://jsfiddle.net/patridge/NQ4uE/

Upvotes: 5

Related Questions