Open njlester opened 3 years ago
Same issue:
File "/usr/local/lib/python3.9/site-packages/google_trans_new/google_trans_new.py", line 188, in translate
raise e
File "/usr/local/lib/python3.9/site-packages/google_trans_new/google_trans_new.py", line 152, in translate
response = json.loads(response)
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 1962 (char 1961)
Hope you can fix this soon.
Change the line 151 in google_trans_new/google_trans_new.py which is:
response = (decoded_line + ']')
to
response = decoded_line
Same issue 😑
151行 response = (decoded_line + ']') 导致json解析错误 修改成 response = (decoded_line) 即可
If you want to use language detect function,
def detect(self, text):
you should fix the line 233
response = (decoded_line + ']') to response = (decoded_line)
This solution worked for me. It should be implemented in the code in the repo and update a new version on pip, this is a major bug.
When can a new release be expected? This is a major bug.
I refactored the translation part of google-trans-new
using httpx
: https://github.com/ffreemt/google-itranslate, not fully tested though.
To install via pip
:
pip install itranslate
The package also provide an async version: atranslate
.
Hi, thanks for fix. Are you going to release the new pip package ?
is it possible to release a new version with that fix?
same issue, waiting for the fix as I can't manually edit the package on my project
Thanks, I edited the file manually and everything worked
I refactored the translation part of
google-trans-new
usinghttpx
: https://github.com/ffreemt/google-itranslate, not fully tested though.To install via
pip
:pip install itranslate
The package also provide an async version:
atranslate
.
Many thanks for pushing this out with the json loads issue fixed. I thought it had been incorporated into google_trans_new but even when I uninstalled/reinstalled the package, the old broken code was still in place. Your version plugged in almost seamlessly to a project where I was using google_trans_new. Only differences being in the way you call it (yes, I actually had to read your instructions) and in the way the target language is specified.
Hello all, I tried to fix by using the new version but I am getting the same error again.
I am trying to decode "mai pareshan hu" which is Hindi for "i am worried" in Django views, but I am still getting error while using the translate()
function.
When user submits the form, it goes into the URL like /urlname?q="<my_submitted_text>"
and receiving it at the view of respective URL. But when I receive it in views, the problem in the translate occurs again.
I tried updating the line 151 as suggested by @CurtisDai. Is there something I am doing it wrong. I appreciate any help I can get.
Thank you in advance.
Change the line 151 in google_trans_new/google_trans_new.py which is:
response = (decoded_line + ']')
toresponse = decoded_line
Change the line 151 and Line 233 in google_trans_new/google_trans_new.py: response = (decoded_line + ']') to response = (decoded_line) # Note the Brackets shall be added
This solution works, confirmed on 18-Jul-2021. Thanks very much~~
Change the line 151 in google_trans_new/google_trans_new.py which is:
response = (decoded_line + ']')
toresponse = decoded_line
Change the line 151 and Line 233 in google_trans_new/google_trans_new.py: response = (decoded_line + ']') to response = (decoded_line) # Note the Brackets shall be added
This solution works, confirmed on 18-Jul-2021. Thanks very much~~
Hello @YeshanMa . Thanks for your help and time. I tried replacing it but it still doesnt work for some other reason. Still, thanks again for the help.
This still doesn't work, hope it gets updated on pip soon, so that I can use google translate on some production systems easily.
any updates, guys? getting the same error
I'm also getting the same error. So the API is not working?
I'm also getting the same error. So the API is not working?
@YeshanMa fix worked for me. I had to modify the code of the package but since then, no issue
Hi @NicoCaldo, can you share how you did it again with the code replacement? I tried to replace the same but didnt work. Thanks in advance.
Hi @NicoCaldo, can you share how you did it again with the code replacement? I tried to replace the same but didnt work. Thanks in advance.
Change the line 151 in google_trans_new/google_trans_new.py which is:
response = (decoded_line + ']')
toresponse = decoded_line
Any update? Same error here.
i change in line 153 and also still the error .. any help plz
I am currently working with kaggle notebook. can anyone help out on how to fix the bug from my end?
i change in line 153 and also still the error .. any help plz
me too,Have you found any way?
Change the line 151 and Line 233 in google_trans_new/google_trans_new.py:
Altering it at both of these positions fixed both translation and language detection.
Change the line 151 in google_trans_new/google_trans_new.py which is:更改 google_trans_new/google_trans_new.py 中的第 151 行:
response = (decoded_line + ']')
to 到response = decoded_line
I committed the modified package to Pypi, use if necessary.
pypi: https://pypi.org/project/google-trans-new-flicker code: https://github.com/FlickerMi/google_trans_new
Translating anything fails with exception "json.decoder.JSONDecodeError: Extra data: line 1 column 300 (char 299)"