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

ReversoTranslator BUG #96

Open
reddere opened this issue Sep 11, 2023 · 7 comments
Open

ReversoTranslator BUG #96

reddere opened this issue Sep 11, 2023 · 7 comments

Comments

@reddere
Copy link

reddere commented Sep 11, 2023

ReversoTranslator is bugged as when words like única are getting passed in the source text field, it throws error: requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

Here is a piece of code to replicate:

from translatepy.translators.reverso import ReversoTranslate

translator = ReversoTranslate()

text = 'Una manera única de conseguir la victoria\n\nJonesyTheGoat'
t = translator.translate(text, 'Italian')
print(t)

Note how if you remove única, it works great. Somehow it throw error even if you replace the ú with a normal u. No idea why, @Animenosekai thanks in advance <3

@ZhymabekRoman
Copy link
Contributor

requests doesn't supports HTTP/2, probably that's why it's throws exception ChunkedEncodingError. Or there is some problem in server side. Anyway, if we send exactly same request with curl, we get useful information about error itself:

{"error":"direction_invalid","errorType":"validation"}⏎

@ZhymabekRoman
Copy link
Contributor

@reddere, as a workaround, please specify the source language of the text, as Reverso recognises text in Catalan. However, the translate endpoint doesn't support Catalan translation:

from translatepy.translators.reverso import ReversoTranslate

translator = ReversoTranslate()

text = 'Una manera única de conseguir la victoria\n\nJonesyTheGoat'
t = translator.translate(text, 'Italian', 'Spanish')
print(t)

@ZhymabekRoman
Copy link
Contributor

I made some investigation and came to conclusion that when we send request from Chromium, even from Icnognito mode, Reverso correctly detects language as Spanish, if we export same request as curl format from Network tab of Devtool and execute it in terminal, we get Catalon language as in requests result. Probably Reverso uses some fingerprinting algorithm to detect the source of incoming requests, I have no better explanations.

@reddere
Copy link
Author

reddere commented Sep 11, 2023

I deeply appreciate the insightful replies @ZhymabekRoman . Unfortunately I cannot set the source language as I'm using the translator to translate from multiple languages (english, spanish and german mainly) to italian. If reverso detects the source of incoming requests, will passing a Chromium User-Agent in headers work?

@ZhymabekRoman
Copy link
Contributor

will passing a Chromium User-Agent in headers work?

Nope

@ZhymabekRoman
Copy link
Contributor

As a workaround, I think you can use Google to detect the language and pass it to Reverso for translation.

@Animenosekai
Copy link
Owner

Animenosekai commented Sep 11, 2023

Hmm requests.exceptions.ChunkedEncodingError is not really common, might need to investigate a bit

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

3 participants