Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
me-suzy opened this issue May 24, 2021 · 4 comments

Comments

@me-suzy
Copy link

me-suzy commented May 24, 2021

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
Copy link
Author

me-suzy commented Jun 6, 2021

another example here, for a wrong translation. Today 06.06.2021

https://snipboard.io/SaML5D.jpg

@niwreg-coder
Copy link

I am experiencing the same issue with bad translations.

@cpeterp
Copy link

cpeterp commented Jul 8, 2021

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
Copy link

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants