Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google translate on my website

I'm trying to embed Google Translate snippet in my website, but for some reason it is not even displayed. I go here: Google tools

Copy this:

<div id="google_translate_element"></div>
<script>
   function googleTranslateElementInit() {
      new google.translate.TranslateElement({
         pageLanguage: 'en'
      }, 'google_translate_element');
   }
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Paste it to my webpage. And I don't see it there.

What am I missing? Some HTML maybe?

like image 843
vlevsha Avatar asked Aug 06 '11 14:08

vlevsha


2 Answers

Here is a working example. I think you are missing "&ug=section&hl={LANGUAGE}" parameters:

My Page Тестирование

<script>
function googleSectionalElementInit() {
  new google.translate.SectionalElement({
    sectionalNodeClassName: 'translate',
    controlNodeClassName: 'translate_control',
    background: '#f4fa58'
  }, 'google_sectional_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>

http://jsfiddle.net/maxim75/H3Wkr/ - working example

like image 144
Maksym Kozlenko Avatar answered Oct 03 '22 07:10

Maksym Kozlenko


In the HTML, the 'control' class element needs to be nested in the 'section' element. :)

like image 26
Colin R. Turner Avatar answered Oct 03 '22 06:10

Colin R. Turner