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

PonsTranslator not working #199

Closed DrRac27 closed 1 year ago

DrRac27 commented 1 year ago

Description

While using PonsTranslator I always get a big output with the names of a few languages, line breaks and spaces. With this diff in deep_translator/pons.py I get the expected output (see below):

78c78,79
<             elements = soup.findAll(self._element_tag, self._element_query)
---
> 
>             elements = soup.find("div", {"class": "result_list"}).findAll(self._element_tag, self._element_query)
86c87
<                 temp = ""
---
>                 temp = []
88,89c89,90
<                     temp += e.get_text() + " "
<                 filtered_elements.append(temp)
---
>                     temp.append(e.get_text())
>                 filtered_elements.append(" ".join(temp))

Would you like a PR?

What I Did

>>> from deep_translator import PonsTranslator
>>> PonsTranslator(source='en', target='fr').translate('awesome')
'\n\n              Arabic\n            \n\n \n\n              Bulgarian\n            \n\n \n\n              Catalan\n            \n\n \n\n              Chinese\n            \n\n \n\n              Croatian\n            \n\n \n\n              Czech\n            \n\n \n\n              Danish\n            \n\n \n\n              Dutch\n            \n\n \n\n              English\n            \n\n \n\n              Estonian\n            \n\n \n\n              Finnish\n            \n\n \n\n              French\n            \n\n \n\n              German\n            \n\n \n\n              Greek\n            \n\n \n\n              Haitian Creole\n            \n\n \n\n              Hebrew\n            \n\n \n\n              Hungarian\n            \n\n \n\n              Indonesian\n            \n\n \n\n              Italian\n            \n\n \n\n              Japanese\n            \n\n \n\n              Korean\n            \n\n \n\n              Latin\n            \n\n \n\n              Latvian\n            \n\n \n\n              Lithuanian\n            \n\n \n\n              Norwegian\n            \n\n \n\n              Persian\n            \n\n \n\n              Polish\n            \n\n \n\n              Portuguese\n            \n\n \n\n              Romanian\n            \n\n \n\n              Russian\n            \n\n \n\n              Serbian\n            \n\n \n\n              Slovak\n            \n\n \n\n              Slovenian\n            \n\n \n\n              Spanish\n            \n\n \n\n              Swedish\n            \n\n \n\n              Thai\n            \n\n \n\n              Turkish\n            \n\n \n\n              Ukrainian\n            \n\n \n\n              Vietnamese\n            \n\n \n\n              Elvish\n            \n\n '
>>> my_local_version_of.pons.PonsTranslator(source='en', target='fr').translate('awesome')
'redoutable'
nidhaloff commented 1 year ago

@DrRac27 Thanks for opening the issue. Sure a PR would be great, PRs are ALWAYS welcome =)