py-googletrans icon indicating copy to clipboard operation
py-googletrans copied to clipboard

Batch translation is not working in 4.0.0rc1

Open ViktorooReps opened this issue 6 months ago • 2 comments

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:

Batch translation does not work.

>>> import googletrans
>>> tr = googletrans.Translator()
>>> tr.translate('test', dest='en')
<googletrans.models.Translated object at 0x101c9c5d0>
>>> tr.translate(['test'], dest='en')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Viktor/PycharmProjects/people-benchmark/.venv/lib/python3.11/site-packages/googletrans/client.py", line 219, in translate
    parsed = json.loads(data[0][2])
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Other information:

 % pip freeze
annotated-types==0.7.0
anyio==4.4.0
certifi==2024.7.4
chardet==3.0.4
distro==1.9.0
dnspython==2.6.1
email_validator==2.2.0
Faker==26.3.0
googletrans==4.0.0rc1
h11==0.9.0
h2==3.2.0
hpack==3.0.0
hstspreload==2024.8.1
httpcore==0.9.1
httpx==0.13.3
hyper==0.5.0
hyperframe==5.2.0
idna==2.10
jiter==0.5.0
openai==1.40.3
pydantic==2.8.2
pydantic_core==2.20.1
python-dateutil==2.9.0.post0
rfc3986==1.5.0
six==1.16.0
sniffio==1.3.1
tqdm==4.66.5
typing_extensions==4.12.2

ViktorooReps avatar Aug 13 '24 16:08 ViktorooReps