lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

Python: google_trans_new - does not translate as correctly as https://translate.google.com/ #35

Open me-suzy opened 3 years ago

me-suzy commented 3 years ago

hello, I use the library of google_trans_new and other google-translate libraries, such as googletrans or PYGOOGLETRANSLATION to translate multiple webpages.

from google_trans_new import Translator

translator = Translator()

The problem is that this library does not translate as correctly as https://translate.google.com/

For example, this line, that I translated from english to belarusian:

Show the superiority of your conscience, by removing the destructive influences of your own feelings' oscillations.

With https://translate.google.com/ the translation is correct:

Пакажыце перавагу свайго сумлення, выдаючы разбураныя павышаныя ваганні ўласных пачуццяў.

but using google_trans_new library, I get a pretty bad translation:

Пакажыце перавагу выкарыстання сум, шляхам выдачы разбуральных уздзеянняў вашых уласных пачуццяў вагаў.

I don't know what can be the problem??? Maybe you must update something... ?

me-suzy commented 3 years ago

another example here, for a wrong translation. Today 06.06.2021

https://snipboard.io/SaML5D.jpg

niwreg-coder commented 3 years ago

I am experiencing the same issue with bad translations.

cpeterp commented 3 years ago

So I'm having the same issue with certain translations too. I checked the requests sent by google_trans_new and translate.google.com's web interface and they appear identical. However, the JSON responses are slightly different. It looks like the response includes the most likely translation along with other probable translations, but in some cases the most probable translation chosen by the google API is not the same as the web interface.

For example, below is the response I got for "was meinst du" (from German to English). The best translation according to google is "what do you mean", but "What do you think" is also included. You can see that 3 options were returned in the JSON but "what do you mean" was chosen first. For some translations though, this response differs when using the google_trans_new package or when using the web interface. Instead, the wrong translation will be prioritized in the response.

[["wrb.fr","MkEWBc","[[null,null,null,[[[0,[[[null,13]],[true]]]],13]],[[[null,null,null,true,null,
  [[\"what do you mean\",null,null,null,'[
    [\"what do you mean\",[2,5]],
    [\"What do you think\",[2]],
    [\"what you mean\",[1]]
]]]]],\"en\",1,\"de\",
'[\"was meinst du\",\"de\",\"en\",true]]]",null,null,null,"generic"],["di",30],
["af.httprm",29,"6581179923932975633",27]]

Because the issue seems to be wonky responses from the Google API, my guess is that the request sent by google_trans_new must be different in some way from the one sent by the web interface. I tried messing around with the headers a little in google_trans_new but nothing seemed to work. Maybe someone just needs to thoroughly check all the headers sent by the web interface against what google_trans_new sends.

If you go to the google translate page and enter a translation, you can find the request by going to https://translate.google.com/?sl=de&tl=en&text=was%20meinst%20du&op=translate and using: Right Click > Inspect > Network > filter: XHR > click on batchexecute?rpcids=MkEWB

xibaibai9527 commented 3 years ago

Ah, I understand. I thought "the translate result is instable" mean sometimes it return 404. Now I konw it mean "the translate result is bad sometimes".