py-googletrans
py-googletrans copied to clipboard
There is an error in translating "cat" into French
Googletrans version:
- [x] 4.0.0rc1
- [ ] 3.1.0a0
- [ ] 3.0.0
- [ ] 2.x
I'm submitting a ...
- [x] bug report
- [ ] feature request
Current behavior:
Traceback (most recent call last):
File "d:\test\python_test_2-17\translater_test\google_test1.py", line 4, in <module>
print(translator.translate("cat", "fr"))
File "D:\python\virtualenv\OCR\lib\site-packages\googletrans\client.py", line 222, in translate
translated_parts = list(map(lambda part: TranslatedPart(part[0], part[1] if len(part) >= 2 else []), parsed[1][0][0][5]))
TypeError: 'NoneType' object is not iterable
Expected behavior:
Steps to reproduce:
Related code:
from googletrans import Translator
translator = Translator()
print(translator.translate("cat", "fr"))
Other information: I found this issue while processing Bing translation, which returned an HTML file instead of JSON format data Later, I used this library and found the same problem.
Same thing for word "users" into Spanish.
from googletrans import Translator
translator = Translator()
print(translator.translate("users", "es"))
Traceback:
Traceback (most recent call last):
File "/home/artic/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
File "<input>", line 4, in <module>
File "/home/artic/PycharmProjects/legaltech_backend/.venv/lib/python3.10/site-packages/googletrans/client.py", line 222, in translate
translated_parts = list(map(lambda part: TranslatedPart(part[0], part[1] if len(part) >= 2 else []), parsed[1][0][0][5]))
TypeError: 'NoneType' object is not iterable