d4n3436 / GTranslate

A collection of free translation APIs (Google Translate, Bing Translator, Microsoft Translator and Yandex.Translate).
MIT License
64 stars 10 forks source link

GoogleTranslate2 produces invalid result #5

Open Nuklon opened 1 year ago

Nuklon commented 1 year ago
GoogleTranslator2 t = new();
string text = "[ZZ_123456_ZZ]";
var r = t.TranslateAsync(text, "tg", "en").GetAwaiter().GetResult();
Console.WriteLine(r.Translation);

This results in: [ZZ_1233456_ZZ] (2x 33). With GoogleTranslator "v1" this works OK.

d4n3436 commented 1 year ago

This is a known issue of GoogleTranslate2 and the JSON RPC API. There's a HTTP header generated by an algorithm (X-Goog-BatchExecute-Bgr) that Google sends with the HTTP request on their website. Without the correct header value the translation will have a lower quality. GoogleTranslator doesn't have this problem because it uses another endpoint.

You should use GoogleTranslator until someone manages to reverse-engineer the algorithm.