Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google translate has stopped working in Chrome

Google translate has stopped working in Chrome but still working in Firefox. The code is below and it was working for long time before now:

<script>
    function googleSectionalElementInit() {
    new google.translate.SectionalElement({
        sectionalNodeClassName: 'can-translate',
        controlNodeClassName: 'translation-control',
        background: '#ffffcc'
    }, 'google_sectional_element');
    }
    var url = top.location.href,
        pos = url.search(/\/\w\w(\W|$)/),
        lang = url.substring(pos+1,pos+3),
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = false;
        ga.src = 'https://translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl='+lang;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
    })();
</script>

At the moment here is error:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtqeel7c with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

If it go to the proposed link, here is suggestion:

Make sure these resources are served with a correct "Content-Type" response header from the list below, as well as a "X-Content-Type-Options: nosniff" response header.

Also there is message at https://translate.google.com/intl/en/about/website/

We no longer provide new access to Google Translate's Website Translator. This change does not affect existing use of the Website Translator.

This has affect in Chrome only, code above is Google only and I've no idea where and how to add "X-Content-Type-Options: nosniff".

UPD: there are both of two necessary headers.

Does Google blocked itself and does anyone know how to fix it?

UPD1: Google translate error began to appear and in Firefox 66.0.1 too. It is

The resource from “https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jttrta1j” was blocked due to MIME type (“application/json”) mismatch (X-Content-Type-Options: nosniff).

It looks like some glitch of translation service, after one page refresh it works, after another - server returns incorrect data, json instead of javascript or something like this

like image 430
Yuri Avatar asked Mar 05 '23 06:03

Yuri


2 Answers

At this point, if you manually delete a cookie with the name "NID" for the host .translate.googleapis.com, you can process the page(CORB error disappears)

By the way, repeated page calls also sometimes remove this error. But the solution to the problem is as strange as its occurrence.

like image 115
Oleg Avatar answered Mar 10 '23 20:03

Oleg


Please open a bug via https://crbug.com/new and try to provide as many details as possible:

  • Did the issue work in Chrome 72 and stopped working in Chrome 73?

  • Is there a repro page that shows the problem? What is the expected VS observed behavior?

  • Does the issue repro without any Chrome extensions present?

  • Does the broken page use AppCache?

like image 31
Łukasz Anforowicz Avatar answered Mar 10 '23 21:03

Łukasz Anforowicz