bpierre/gtranslate

google api needs to use POST for long requests

mote0230 opened this issue · 3 comments

Otherwise it returns error 400
Cutoff seems to be around 1359 characters

fixed 2ceeece
the code might use some styling

Still some issue with non-western scripts

Relevant code in chrome's official translate extension:

function(a, b, c, d) {
        if ("" != a) {
            window.selection = a;
            a = new Wf("gtx", "https://translate.googleapis.com");
            var e = chrome.i18n.getUILanguage ? chrome.i18n.getUILanguage() : "en";
            d = null != d ? d : "auto";
            var f = Ag();
            c = new M("source=" + c);
            var g = window.selection,
                k = a.a + "/translate_a/single",
                l = new M,
                v = new M;
            window.EGGS_JANGO && ("qab" == d && (l.set("slo", "qab"), d = "en"), "qab" == f && (l.set("tlo", "qab"), f = "en"));
            l.set("client", a.c);
            l.set("sl", d);
            l.set("tl", f);
            l.set("hl", e);
            Mc(l, "dt", ["t", "bd"]);
            l.set("dj", "1");
            c && l.g(c);
            v.set("q",
                g);
            Yf(a, k, l, v, t(a.f, a, b))
        }

  Yf = function(a, b, c, d, e) {
            c = c.toString();
            c += "&tk=" + Xf();
            d = d.toString();
            var f = "POST";
            b += "?" + c;
            2E3 > c.length + d.length && (f = "GET", b += "&" + d, d = "");
// ...
}