Animenosekai / translate

A module grouping multiple translation APIs
GNU Affero General Public License v3.0
515 stars 60 forks source link

Result mismatch Google Translate #80

Open joeperpetua opened 1 year ago

joeperpetua commented 1 year ago

Hi guys, hope you are doing well. I know that you are pretty busy working on v3 and may are already aware of this already, but just in case I open this issue.

When using the GoogleTranslate service, the translation is different from what we get in the website/app:

[1] Google translate result: Sincerely sorry for not having replied to your messages more quickly, when the file is transmitted to the developers, we temporarily no longer have visibility on it.

[2] translatepy result: Honestly sorry not to have answered your messages faster, when the file is transmitted to the developers, we do not temporarily have more visibility on it.

Any ideas of what/why could be this caused? I actually tried changing the session header as per #79 but it did not have any effect on the translation result.

[1] image

[2]

Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import translatepy
>>> translatepy.Translator().translate("Sincèrement navré de ne pas avoir répondu à vos messages plus rapidement, lorsque le dossier est transmis aux développeurs, nous n'avons temporairement plus de visibilité dessus.", "en")
TranslationResult(service=Google, source=Sincèrement navré de ne pas avoir répondu à vos messages plus rapidement, lorsque le dossier est transmis aux développeurs, nous n'avons temporairement plus de visibilité dessus., source_language=fra, destination_language=eng, result=Honestly sorry not to have answered your messages faster, when the file is transmitted to the developers, we do not temporarily have more visibility on it.)
>>>
ZhymabekRoman commented 1 year ago

Related issue: https://github.com/Animenosekai/translate/issues/22#issuecomment-913048735 Try to use GoogleTranslateV2 class as workaround: https://github.com/Animenosekai/translate/issues/22#issuecomment-922500361

joeperpetua commented 1 year ago

Thanks, that works well! So I understand that the GoogleTranslate service defaults to GoogleTranslateV1, right? I assumed it used the V2 by default 😅

Animenosekai commented 1 year ago

Thanks, that works well! So I understand that the GoogleTranslate service defaults to GoogleTranslateV1, right? I assumed it used the V2 by default 😅

Yup for now GoogleTranslateV1 is tried first

https://github.com/Animenosekai/translate/blob/1033e1f3eddb9f2d66cb4d7ffaeb6723864e10cc/translatepy/translators/google.py#L78-L86

The reason is that V1 should be the one used on the website, but we can't generate the right tokens for now : https://github.com/Animenosekai/translate/issues/22#issuecomment-913921088

ghost commented 1 year ago

@Animenosekai so v2 better than v1?

Animenosekai commented 1 year ago

@Animenosekai so v2 better than v1?

Well without reverse engineering the token generation, yes (maybe?)