AidanWelch / google-translate-api

An updated free and unlimited API for Google Translate :dollar: :no_entry_sign:
MIT License
137 stars 19 forks source link

Autocorrect not properly applied to translations from certain networks #18

Open AidanWelch opened 1 year ago

AidanWelch commented 1 year ago

Certain networks require the X-Goog-BatchExecute-Bgr header to be sent on requests, or the autocorrect will not be applied to some translations(seemingly typos where a letter is dropped, such as "I spea Dutch!" instead of "I speak Dutch!").

The code for generating this header I believe is found in this static script.

I believe in xH.prototype.s()

This would likely take a while to fix.

RipperTs commented 1 year ago

Certain networks require the X-Goog-BatchExecute-Bgr header to be sent on requests, or the autocorrect will not be applied to some translations(seemingly typos where a letter is dropped, such as "I spea Dutch!" instead of "I speak Dutch!").

The code for generating this header I believe is found in this static script.

I believe in xH.prototype.s()

This would likely take a while to fix.

Hello, can you generate this request header parameter value based on this static script?

AidanWelch commented 1 year ago

@RipperTs As far as I know, yes, but I'm not certain.

ttys3 commented 1 year ago

no. that' s wrong.

xH.prototype.s=function(){var a=Swa([_.Ffa,_.Hfa,_.Ifa,_.Qr,_.Kfa,_.Rfa,_.Sfa,_.Tfa,_.Nk]); is just a feature id to request api endpoint map.

I debug and confirmed that. it has nothing to do with the header.

ttys3 commented 1 year ago

the real code is in the HTML page. and it is encrypted.

ttys3 commented 1 year ago

if you debug in dev tools, it may generate a wrong token like:

["FNL82,0,1,66,24095,60,24097",null,null,23879,987,null,null,0,"2"]
AidanWelch commented 1 year ago

I don't have the time to look into this more, but if someone can figure it out I would happily merge the PR!