ssut / py-googletrans

(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.
http://py-googletrans.rtfd.io
MIT License
3.93k stars 726 forks source link

There is an error in translating "cat" into French #394

Open goshut opened 10 months ago

goshut commented 10 months ago

Googletrans version:

I'm submitting a ...

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.

ArtiomOn commented 8 months ago

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
yellowtapes commented 1 week ago

Apparently the word "Obvious" for spanish well.