Google webtranslate integration

posts: 45 Germany

Hi, I’ve just upgrade from Tikiwiki 8.4 to 9.1 and so far everything works very smoothly, phew. Website link is http://www.eq2wiki.net/ .
Now I would like to add Google webtranslate to my pages and I’m stuck with step 2. Step one was adding the Google generated meta information to the head of the website in the “Look & Feel” section. Step 2 is now adding

function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'de', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, multilanguagePage: true}, 'google_translate_element');

into the top of the body, preferentially the same area where the “edit page”, “save to noteblock” etc. buttons are. But I can’t figure out where the template for this is or how else I add this.
There should be a general template for that no?

Edit: Can someone tell me how to add code that is not “sanitized” nor executed when hitting submit here? Neither “code” nor “non-parsed” do that with the Google Translate java script code.

posts: 45 Germany

Ps: I’ve tried adding the above into the “html at end of body” under “look and feel” and it completely kills the page, smarty error, exception etc etc.
And when I add it into the javascript box there is no error message but the translate button does not show?
Adding the Google Translate javascript snippet as html parsed module kills smarty too.

posts: 1506 Canada

I tried on dev.tiki.org and I get:

There is a problem with your custom module “Google_Website_Translator”:

Syntax Error in template “78f9d6a039150eff4b69bdc56aa9d7767be3baea” on line 3 “new google.translate.TranslateElement({pageLanguage: ‘en’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’);” - Unexpected “: “, expected one of: “}” , ” ” , ATTR

It works in a wiki page, but not via a module...

I started a doc page: Google Website Translator

posts: 45 Germany

Awesome, thanks a lot. Is there a way to add this automatically to any wiki page? I’m looking over that huge template list but I’m a bit lost which template that might be ... Or is there another way than templates?

Edit: I tried to add it to header.tpl but it gives the same smarty error killing the page no matter if I use it with the htmlPlugin or not.

posts: 45 Germany

I found this: http://doc.tiki.org/Custom+Code+HowTo+-+jQuery
Is this feasible than?

{HTML()} function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: ‘en’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’); } {HTML}

{jq} $.getScript(‘//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit’, function() { $.googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: ‘de’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’);} }); }); {/jq}

Because adding that into the custom javascript in the admin look and feel section does not add the website translate button to any page - and the flashplayer plugin is broken now. Adding it to the custom body end section fixes the flashplayer but still no button.

posts: 45 Germany

Hm. Where do I have to put that? If I put it into the javascript section of the admin -> look and feel -> customize nothing happens and the flashplayer plugin is broken again.

Edit: Ah hm that works as custom module now, thanks. But I wanted to integrate it into my template on www.eq2wiki.net to be visible next to the search box on the very top. So how to I put it there? Is that the header.tpl ?

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.