Jump to content

Created Module For Google Translate


BarNet

Recommended Posts

Hi all

 

This is my first attempt at a module and I thought all was cool but it is not getting accepted in the back-end. I have tweaked and re-uploaded half a dozen times ( and more!) but really need someone to run their eyes over it and let me know what I have done incorrectly.

 

php page is:


<?php
class googlelanguages extends Module{


function __construct(){


$this->name = 'googlelanguages';
$this->tab = 'Blocks';
$this->version = 0.2;


parent::__construct();


$this->displayName = $this->l('Google Languages');
$this->description = $this->l('Adds Google Languages block');


}

function install()
{
if (!parent::install())
return false;
if (!$this->registerHook('top'))
return false;
return true;
}


function hookTop($params){
return $this->display(__FILE__, 'googlelanguages.tpl');

}
}
?>

 

and then the .tpl code:


<!-- Block languages module -->
<div class="languages_block_top">
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
 new google.translate.TranslateElement({
   pageLanguage: 'en',
   includedLanguages: 'zh-CN,zh-TW,en',
   multilanguagePage: true,
   layout: google.translate.TranslateElement.InlineLayout.SIMPLE
 }, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<!-- /Block languages module -->

 

Can anyone see any bloppers?

 

Thanks in advance

Catherine Barclay

 

PS. Happy New Year!!!

Link to comment
Share on other sites

  • 3 weeks later...

Hi! I am using latest prestashop version but in google translation is not working for me, it keeps on loading and loading and shows some url . is there a module I must add? do you mind giving me the link?

I do not understand why in version 1.4.4.1 worked so well and now it's giving me troubles.

Link to comment
Share on other sites

  • 2 weeks later...

Hi All!

 

I have also problems with translating because the google translator is not free and I use the Prestashop (1.4.6.2) in Hungary.

 

I found the Micosoft Bing translator. It is free and it has a good API.

 

I made some changes in gg-translate.js to use Bing for translation.

 

 

You need to get an Appilcation Id for Bing translator.

Follow: http://www.microsoft.com/web/post/using-the-free-bing-translation-apis

 

In gg-translte.js you have to change your App ID

var myAppId = "Your app Id is here";

 

You can download this javascript file, and copy into js/ folder.

http://weboldal-programozas.hu/gg-translate.php

 

Good luck,

Zsolt

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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...