-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
When I compared this translation with Google Translate, I got a different result. #131
Comments
Hello! Could you share the exact discrepancies, that you've found? |
Hi vitalets, Thank you for the reply. Here is the text in Chinese: The result we have from your library: Google translate's result: You are not probably speaking Thai but the discrepancies can be found in many cases. Text: "How was work today?" The good results are the ones that comes from Google Translate. The incorrect translations are really off, and occasionally they don't make sense. I actually have tried the same examples on another NodeJS library named "@iamtraction/google-translate". The results are identical to yours. I think and according to our users, the discrepancies only started to occur a few days ago. Regards, |
Could you show the code snippet, how do you perform the request? |
The code is copied straight from the npm: The version number is 9.2.1 import { translate } from '@vitalets/google-translate-api'; |
I've tested with russian and confirm the discrepancy. const { text, raw } = await translate(sourceText, { to: 'th' });
console.dir(raw, { depth: null }); |
The same question, I have raised two issues in other repos, I suspect that this is because Google uses different models for different APIs. It seems Google is going to make changes to these undocumented APIs. :( index.js
output:
|
@vitalets here is the raw:
|
Frankly, not sure that we can solve it, any ideas would be appreciated. Google translate website performs the following request:
UPDATE: |
@vitalets The interesting thing is that this has only happened to me in the last month. But it seems that this phenomenon has occurred to others in early 2024 or even before. Do you have any thoughts on this? By the way, I tried to use different IP addresses or machine to make requests to that API, but all the results I got were wrong. If it is not associated with something on the client side, how can it become unusable after a certain "accidental" point in time? |
Just one idea, maybe google rolls out this feature gradually? |
Google's forum Q&A staff has denied any free undocumentary APIs, I guess these APIs were used in obscure places and Google has figured it out and is phasing them out... Is next step to imitate the web translation request through reverse engineering? Maybe there are other easier ways... |
One of the approaches is to utilize headless browser - navigate to google translate page and perform translation request. |
Thank you, I thought of this, and I'll try it. |
I haven't tried headless browser yet, but others mentioned a lib which is not affected in another issue. That py lib uses another api 'https://translate.google.com/m', and the api can return the entire translation page, which contains the correct translation results, without the need for a specific header. I debugged in Python env and verified it can work without specific header in Postman. Test content
|
@Waste2Time I tried the 'https://translate.google.com/m' api, I can verify that the results still are not the same.
compare to
This just gets me an idea that should there be another api out there we don't know about? that returns the same result. |
@thawon base on your giving /m api, try to translate the given adv sentence in web and select ja as source language, you will see the same result |
@Waste2Time my mistake. I am sorry. Yes, when changing the source language (sl), the results are the same. Great work :) |
Google is trolling us 🙂 |
Now deep-transtalor py lib is failed, it returns as follows: Error 500 (Server Error)!!1500.That’s an error.There was an error. Please try again later.That’s all we know. so crazy. edit: the api is working but returns different result, I'll submit a new issue in that repo... |
@vitalets Chrome also has two built-in google translation methods, partial translation and whole web translation. I caught messages and analyzed them. Partial translation uses get method and puts what needs to be translated as base64 in header, unfortunately there is a part before and after the base64 encoding that I can't find out how to get it. But the whole web translation is eaiser, it use post method, and just needs x-goog-api-key in header. I guess it's unique and unchanging for every user. I didn't make many changes to reuse the whole web translation api in postman and verify it. I hope this information is useful to you. :) btw, I hope google won't make any more changes to translation api |
@Waste2Time And what is the value of the "x-goog-api-key" ? Or do you have an example? |
You can get it from google cloud service as normal way I guess, it's unique to each user. But I got it by catching requests. |
@Waste2Time thanks for the interesting insights. Do you see the these requests when un-authorized in chrome / incognito page? |
Okay, I feel like I have it all figured out. The whole page tranlsation function uses google cloud serivce, so the key is the same for everyone. I have applied another api key in google cloud and replaced the old with I applied, it returns |
@Waste2Time Can you share a screenshot with the entire request Chrome makes to translate a website? |
Hello,
And the result:
|
Hello! First of all, thank you for your valuable reminder in the translation plan.
We have fully discussed the plan, but we still hope to ask you about character escape and line break processing in HTML communication. Thank you again for your reminder and look forward to your valuable suggestions. Best wishes, |
Hi, you mentioned earlier that you tried to reverse engineer the minimized script x-goog-batchexecute-bgr that does the calculations on the Google Translate page, but failed. How is your progress on this issue now? Have you encountered any new challenges or found any new clues? |
I also tried using Cypress to open a browser window to point to translate.google.com to give me the translation but it's also giving me the same translation as this module is. When I open the same exact URL that cypress generates from my script into a normal chrome window, it gives me the correct translation. I tried using the same user agent headers in my cypress test but it still didn't work. |
It is very complex, I think unless we reverse engineer Chrome, we can't figure out what's in that header. In fact, I have tried to reverse Chrome using dynamic or static methods half a month ago, but to no avail. I have very little knowledge in the field of reverse engineering. What I found about this header is that, obviously, the translated content exists in this header in the form of BASE64 encoding, but there are parts of the prefix and suffix that I can't understand where they come from and what they represent. |
The translation request using the /v1/translateHtml endpoint did not work as expected. For instance, when translating the text "你是個好人" with the following input: |
Google's faulty I guess. Considering in the api is used in chrome, have you tried to translate goolge pages including "你是個好人"? I tried and find most search result including traditional chinese wasn't be translated whether to en or de, but simplified Chinese content is ok. |
If the source language is set to Traditional Chinese (zh-TW), it can be translated. |
I don't know German so I can't tell if the translation is poorer but I suggest you try to translate your example in google translate website, the website result is the same with what you provide. A possible explanation is it's the faulty of google translation with traditional chinese i guess. |
Yes, Google Translate doesn't work well with Traditional Chinese. Thank you for your answer. |
Hi there!
We've noticed some users mentioning a recent dip in translation quality, and I've done some testing myself, comparing your library's results with Google Translate. I've found some discrepancies, with Google Translate sometimes performing better. Any insights you could share on why this might be happening would be greatly appreciated!
Regards,
Thawon Uttamavanit
The text was updated successfully, but these errors were encountered: