Jump to content

Google Website Translator Gadget - theme implementation


Recommended Posts

Hello.

 

I wanted to insert Google Website Translator Gadget to the header.tpl to use google translator in my PS.

 

The code works for static pages  (see www.umarosa.sk - my friend web) but when I insert this code to directly to theme header.tpl, the ERROR occurred and there s just blank page, so it completely brake the page.

 

Code:

<DIV id=google_translate_element></DIV>
<SCRIPT type=text/javascript>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'sk', includedLanguages: 'de,en,hu,pl,ru', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</SCRIPT>

<SCRIPT type=text/javascript src="ub_files/element.js"></SCRIPT>
</DIV>

You can generate your own google code on: https://translate.google.com/manager/website/ .

 

So I tired to Bing translator and same result - just blank page.

Code:

<div id='MicrosoftTranslatorWidget' class='Dark' style='color:white;background-color:#555555'></div><script type='text/javascript'>setTimeout(function()[spam-filter]var s=document.createElement('script');s.type='text/javascript';s.charset='UTF-8';s.src=((location && location.href && location.href.indexOf('https') == 0)?'https://ssl.microsofttranslator.com':'http://www.microsofttranslator.com')+'/ajax/v3/WidgetV3.ashx?siteData=ueOIGRSKkd965FeEGM5JtQ**&ctf=True&ui=true&settings=Manual&from=sk';var p=document.getElementsByTagName('head')[0]||document.documentElement;p.insertBefore(s,p.firstChild); [spam-filter],0);</script>

Code from: http://www.bing.com/widget/translator .

 

Also this code works for static pages, just cooperation with PS scripts makes the site broken - just blank site without any content. 

 

Is it possible to implement google, or bing translator directly to theme in this way?

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

I used the "Belvg Blocks Constructor " module, to add this google translation widget in my shop (and many others, this module is fine).  This code (generated by Google)  is in 2 parts :

- 1 part to put before "/head " (and I don't know in which file) ?

- 1 part to put where you want the text appears (for this part, I used Belvg Module)

The widget works,  but I can't used Google analytics tracking, I suppose because I don't put the first part of the code...

Does someone have a solution ?

 

 

Accessoires pour mariage et ceremonie

Link to comment
Share on other sites

  • 1 month later...

I actually have the same problem. It seems like this part of the snippet collides with PS scripts somehow. Hope somebody has a solution, as it seems it should be pretty easy to fix for an experienced programmer.

<script type="text/javascript">function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'cs', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script>
Link to comment
Share on other sites

  • 1 month later...

I found this is an another thread and seemed to work:
 
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Edited by vishnuo (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Dear All PS user,

 

I would like to share ,how to use Google translate gadget on Prestashop very easy way. This is mgiht be help,

First :download HTML box module free from here ...https://mypresta.eu/modules/front-office-features/html-box.html

& intsall it.

Second: Go to https://translate.google.com/manager/website/ and sign in to your Google account when you are prompted to.,,,,,& follow the steps than get a code from there..

Third : The paste the goodle translate code on HTML box and  select the HEADER option.

Test your machine translation .......:-)

 

 

This way works for me ...try it ...

have a good day!

Anaa

Edited by Anaa (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I did your solution Anaa but unfortunatly it doesn t work yet

I put this :

<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'fr', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

And the result :

capture.jpg

If you can help me

Thanks

  • Like 1
Link to comment
Share on other sites

Hi Sboule

 

Seems it's working very well on your website...I use G-translate to Chinese... very well working

 

See attachment image...French and many more languages there....

 

Remember clear cache all the time whenever you do changes...ctrl+F5 .....after that you see the result of your changes.....:-)

 

 

Have a good day

Regards

Anaa

.

 

 

 

 

 

post-995228-0-80300100-1443972925_thumb.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...