Closed MaxBrain closed 3 years ago
This probably is because of the gender-specific translate results. I will investigate and fix it soon.
I'm getting a similar issue, it seems whenever Google gives two results it fails.
[['wrb.fr', 'MkEWBc', '[[null,null,null,[[[0,[[[null,3]\n]\n,[true]\n]\n]\n,[2,[[[null,4]\n,[4,24]\n]\n,[false,true]\n]\n]\n]\n,24]\n]\n,[[[null,"\nPhraxāthity̒ kảlạng ca tkdin",null,null,null,[[null,[""]\n]\n,["\n"]\n,["พระอาทิตย์กำลังจะตกดิน",["พระอาทิตย์กำลังจะตกดิน","ดวงอาทิตย์เป็นเรื่องเกี่ยวกับชุด"]\n]\n]\n]\n]\n,"th",1,"en"]\n]\n', None, None, None, 'generic'], ['di', 63], ['af.httprm', 63, '-9129644094679872904', 37]] sequence item 0: expected str instance, NoneType found
@noaho Thanks for giving me the raw response. I'll fix it within a few days.
Thank you for the great project 😊
Hello! I have the same problem too. @ssut thank you very much for continuing with the project :D Regards.
Hi! any solution for this problem?
@ahmedbr I'm still working on it. Give me a little time please.
@ahmedbr I'm still working on it. Give me a little time please.
Thank you so much for your efforts bro, I've just faced the problem and wanted to ask whether it's been solved. Thanks again. 😄
I think I have the solution. Replace this line 222 of googletrans/client.py with this
try:
translated_parts = list(map(lambda part: TranslatedPart(part[0], part[1] if len(part) >= 2 else []), parsed[1][0][0][5]))
except TypeError: # because of the gender-specific translate results
translated_parts = [ TranslatedPart(parsed[1][0][1][0], [parsed[1][0][0][0], parsed[1][0][1][0]]) ]
Gender-specific translations now work.
>>> translator.translate("Author", src="en", dest="de").text
Autor
(This is my first comment on github, I don't know how to put this code snippet in your pull request)
I think I have the solution. Replace this line 222 of googletrans/client.py with this
try: translated_parts = list(map(lambda part: TranslatedPart(part[0], part[1] if len(part) >= 2 else []), parsed[1][0][0][5])) except TypeError: # because of the gender-specific translate results translated_parts = [ TranslatedPart(parsed[1][0][1][0], [parsed[1][0][0][0], parsed[1][0][1][0]]) ]
Gender-specific translations now work.
>>> translator.translate("Author", src="en", dest="de").text Autor
(This is my first comment on github, I don't know how to put this code snippet in your pull request)
Thanks for your reply, but this doesn't work for me
Use this for google translation and it is working fine https://pypi.org/project/pygoogletranslation
Thank me later
Hi, Still any solution to this issue? Can I work on this?
@mr2rm You are more than welcome to work on this :)
@ssut @mr2rm Is there a reason it's not fixed yet? I ask because I tested the change of vbastianpc and it fixed the issue in my case.
@ahmedbr do you still have a way to reproduce your issue?
@kidburglar That's because I couldn't reproduce it. It seems gender-specific translation won't return in response anymore.
Same error here, it seems the issue still exsits.
@mr2rm
I will try to find few case where I can reproduct the issue. I noted that it was because the gender like you said but also if you got an URL the answer from google is not the same.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
incorrect from en to fr gives this error
Actual code to reproduce
python3
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from googletrans import Translator
>>> translator = Translator()
>>> print(translator.translate("GREAT", src="en", dest="es").text)
The code from the first post still crashes
print(translator.translate("Author", src="en", dest="de").text)
Still an issue. Any gendered word causes this. Another example:
translator.translate("white", src="en", dest="es")
I still have this problem when running the code like this:
df['text_en'] = df['text'].apply(lambda x: translator.translate(x, src=es, dest='en').text )
However, when I take out the src=es
part, it does run - but it gets a timeout after 1,5h.
translator.translate("modern" , src="en", dest ='es')
returns an Error:
TypeError: 'NoneType' object is not iterable
It looks like it has to do with the gender-specific translate. As "modern" in spanish is "moderna" and "moderno" depending on the gender
No one ever updated this thread, so I discovered this from stackoverflow, but this issue has already been solved. If you do "pip install googletrans==3.1.0a0" it will give you the first result of a gender-specific translate, no longer giving you this error.
No one ever updated this thread, so I discovered this from stackoverflow, but this issue has already been solved. If you do "pip install googletrans==3.1.0a0" it will give you the first result of a gender-specific translate, no longer giving you this error.
The version googletrans==3.1.0a0 has this problem too .
Still an issue. Other examples:
translator.translate('ALPINE', src='en', dest='es') translator.translate('Armenian', src='en', dest='es')
I don`t know if someone explains here what is the source of this problem.
I mapped that it happens when the translation returns two or more options.
An example is the word "Automatic". When this word is translated for Portuguese without context can return two options, "Automático" or "Automática".
I think that you can create a parameter to define which genre the code needs to return male or female.
Was there any solution to this error, other than the try
block suggested here?
@MFRS Thank you - worked perfectly!
No one ever updated this thread, so I discovered this from stackoverflow, but this issue has already been solved. If you do "pip install googletrans==3.1.0a0" it will give you the first result of a gender-specific translate, no longer giving you this error.
@MFRS This work for me, be sure to restart session if you are running on colab
Googletrans version:
I'm submitting a ...
Current behavior:
Expected behavior:
I expect the "Author" word in deuch
Steps to reproduce: