Skip to content
Advertisement

Google Translate has stopped working on Chrome, Safari and Opera (still works on Firefox)

Some time ago the Google section translate function has stopped working on most browsers (excluding Firefox), resulting in blank page with “about:blank#blocked” address when someone click on TRANSLATE link under the post (example post, does not need to log in or register to use translate feature: https://www.elvikom.pl/hp-probook-6560b-cure-uma-hr-hpb-mv-mb-v1-sam-sie-uruchamia-t65407.html).

I found that piece of code on stackoverflow: Google Translate shows blank screen in Chrome but I do not know where to place it exactly. Tried to add it right before closing </head> tag as well as right after opening <body> tag but cannot get this code working.

My code right after opening <body> tag (still works on Firefox):

<script>
function googleSectionalElementInit() {
  new google.translate.SectionalElement({
    sectionalNodeClassName: 'goog-trans-section',
    controlNodeClassName: 'goog-trans-control',
    background: '#f4fa58'
  }, 'google_sectional_element');
}
</script>
<!-- IF S_USER_LANG eq 'pl' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=pl"></script>
<!-- ELSEIF S_USER_LANG eq 'ru' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=ru"></script>
<!-- ELSEIF S_USER_LANG eq 'en' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>
<!-- ELSEIF S_USER_LANG eq 'sl' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=sl"></script>
<!-- ELSEIF S_USER_LANG eq 'de' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=de"></script>
<!-- ELSEIF S_USER_LANG eq 'it' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=it"></script>
<!-- ENDIF -->

And my template (html) code:

<div class="goog-trans-section">{postrow.MESSAGE}<br /><br /><a href="javascript:void(0);"><span class="goog-trans-control"></span></a></div>

Advertisement

Answer

Just a moment after I have posted my question, I’ve tried to put that suggested code inside the function googleSectionalElementInit() function. So my current code right after opening <body> tag looks like that:

<script>
function googleSectionalElementInit() {
  new google.translate.SectionalElement({
    sectionalNodeClassName: 'goog-trans-section',
    controlNodeClassName: 'goog-trans-control',
    background: '#f4fa58'
  }, 'google_sectional_element');
 $(document).ready(function(){
  setTimeout( function() {
   $(".goog-te-gadget-link").click(function(){
    $(this).attr('href', 'javascript:;');
   });
  }, 2000);
 });
}
</script>
<!-- IF S_USER_LANG eq 'pl' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=pl"></script>
<!-- ELSEIF S_USER_LANG eq 'ru' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=ru"></script>
<!-- ELSEIF S_USER_LANG eq 'en' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>
<!-- ELSEIF S_USER_LANG eq 'sl' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=sl"></script>
<!-- ELSEIF S_USER_LANG eq 'de' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=de"></script>
<!-- ELSEIF S_USER_LANG eq 'it' -->
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=it"></script>
<!-- ENDIF -->

And now the translate function works perfectly fine on Chrome, Opera and Safari 🙂

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement