nidhaloff / deep-translator

A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.
https://deep-translator.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
1.61k stars 185 forks source link

Linguee French-to-English translation not working #176

Closed wf001 closed 1 year ago

wf001 commented 1 year ago

Linguee French-to-English translation not working

Description

Hi, thank you for publishing such a useful plugin! I noticed that Linguee’s French-to-English translation didn’t work. And it seems that English-to-French, French-to-German, German-to-French also doesn’t work. I suspect it’s because the URL format of Linguee(such as path and query) has been changed as following.

the URL deep-translator using

https://www.linguee.com/fr-en/translation/courir.html

the correct(and valid) URL

https://www.linguee.com/english-french/search?source=french&query=courir

If you guys are OK, I would be interested in contributing this.

What I Did

(expected returning 'run')

>>> from deep_translator import LingueeTranslator
>>> res = LingueeTranslator(source="fr", target="en").translate("courir", return_all=False)                        
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/share-ws/common/deep-translator/deep_translator/linguee.py", line 77, in translate
    raise ElementNotFoundInGetRequest(elements)
deep_translator.exceptions.ElementNotFoundInGetRequest: [] --> Required element was not found in the API response
wf001 commented 1 year ago

Tried to fix this, send PR. See https://github.com/nidhaloff/deep-translator/pull/179.