-
Notifications
You must be signed in to change notification settings - Fork 740
Feature/enhance use of direct api #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/enhance use of direct api #237
Conversation
fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
I can see travis went through. If one look at the errors this is due to gtoken.py test which cannot stably work anymore as it is the origin of the problem !!! This means no pull request at all can be done, we seem to be in a deadlock. |
I'll take a look and consider remove that test if it doesn't work out. |
I know you well know your job, no doubt, but just to mention here that the objective is to have a different way of working with the service url that adresses the api with the gtx client and no need for a token. |
When I ran the code, at times I am getting same error once in 3 tries error in result (AttributeError: 'NoneType' object has no attribute 'group') But actually it solved my other problem, from yesterday where I raised an issue that Output from translator is same as Input. Here is the reference to issue #246. This code actually when it is not giving error , gives me proper output like before. Not sure , how it had fixed , will check the code and try to figure out. Thanks to @alainrouillon for this. |
do you check it for multiple texts? I tried and get output the same as input after addition these fixes |
@adkuln I used proxy for each request , at times it shows same error like NoneType object has no attribute group but while giving output it is giving me proper translated output . Anyways , I ll check for couple of days and will notify the situation. |
@adkuln : Hi, not sure I understand 'multiple texts'. For sure this fix aims to have similar behaviour as existing code, just uses a different end client to do the job. |
@mohamedniyaz1996 : glad it helped. But I'm surprised to read you got into error as I ran 100+ tests without any problem. |
@alainrouillon , I have been using within Translator object with proxies parameter which might have caused this issue, let me try without proxies and check. |
@mohamedniyaz1996 : when creating Translator you have to define the service url as : translate.googleapis.com |
i tried with proxies and after N trials, i got not-translations, but original texts from api |
@adkuln: Hi, as I said to Mohamed, please refer right service url (translate.googleapis.com). |
Below provided the code-block
If I make service_urls to be translate.googleapis.com it is not working and moreover I am seeing for all cases, I again starting to get same input as output. Please correct me if I am not using Translator() object in adherence. |
Please ensure you have dowloaded the whole branch and replaced your local py-googletrans with this code. There are impacts to drive code execution properly considering the service url you choose. If translate.googleapis.com you don't use the same end client that does not required any token. Please ensure as well that your proxy allows to reach the endpoint. |
@alainrouillon , Thanks for the suggestion, My local existing old googletrans didnt get replaced - Now it is working with no issues. Let me test for 10-20 thousand small strings and will monitor if anything breaks. For others, who are reading, I followed below steps to delete existing googletrans and replaced with new code from @alainrouillon :
That's it! It works like a charm. To check if Updated code got installed, I executed below block:
Now, in-real it seems like solving the problem of #246. Thanks @alainrouillon for this. |
Thanks for your PR @alainrouillon , I have tested your PR it's working great, just in case someone it still having issue you can follow what @mohamedniyaz1996 wrote or can also do this way:
And now the below code should work fine: from googletrans import Translator
translator = Translator(service_urls=['translate.googleapis.com']) # At direct pip install,this service_url : translate.googleapis.com will not work , this is the indicator that new code had been installed
translated_text = translator.translate("सभी एक में अश्वशक्ति रंग लेजर प्रिंटर",dest="en")
print(translated_text.text) Update: 26-11-2020 Anyone facing issue like what I faced, can try this Thanks |
@ssut |
Hi, i repeat your steps for 700 steps: |
I still debate on whether releasing this to PyPI is enough because this is a temporary workaround that can't help everyone suffering the same issue. |
Yes we can try this |
I will try to do that tomorrow night (GMT+9 here.) |
Good afternoon, What's wrong with the googletrans library? When calling the .translate function, an error occurs |
Please note that I used proxies to avoid such bottle-neck cases. |
All the same, the same does not work, can I somehow do it wrong on the server? |
Hi, there is something still wrong in gtoken.py: |
Sure the gtoken function cannot work anymore the way it was. If one still uses service url to point to usual translate.googletrans.xxx it will not work. This feature is a fix to be able to use safely another service url to point to a different end client, without any token. |
🎉 New Alpha Version ReleaseI've released [email protected] on PyPI and it seems to be working. Note that you all have to specify the package version like: |
Thank you Suhun. Hope people have good use of it and got the fact they have to use a specific service url. |
hi i have used many method to over come this issue but result is negative , then i searched many and finally got this https://github.com/lushan88a/google_trans_new this post may useful for you guys |
Now it has stopped sending back translated text, it returns the original only. |
Something that may be useful is to use a VPN while the program is running (I'm using the googletrans alpha version). That way it starts translating to the "dest" language again. |
Hello! I have put a new issue please refer here! Thank you guys! you guys are AWESOME! |
Hello, I do not get any errors but my code does not translate either. It was translating at first, now it is not doing anymore, what should I do? |
I used the git clone command with the given branch, and for me the api actually translates and works fine. I uninstalled it and reinstalled it multiple times and it keeps working fine for me, I'm using Python 3.7.x, maybe that does something with it |
AttributeError: 'NoneType' object has no attribute 'translate' Why I get this error? |
Okay, when I use 3.9 I get this error. If I down to 3.7 I get AttributeError: 'NoneType' object has no attribute 'group' error, it was worked fine yesterday I don't understand why it is not working again. The code I tried is: from googletrans import Translator translator = Translator(service_urls=['translate.googleapis.com']) # At direct pip install,this service_url : translate.googleapis.com will not work , this is the indicator that new code had been installed Also, the people who suggest google_trans_new it does not work as well. |
Looks like with the rc-1 version the multiple-inputs use case is indeed broken? Not sure if this is part of a release already, or already fixed. |
* fix: issue ssut#234 - extend service url to direct api fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token * fix: issue ssut#234 - extend use of direct api fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token * fix: issue ssut#234 - extend use of direct api fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token * fix: issue ssut#234 - extend use of direct api fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token * fix: issue ssut#234 - extend use of direct api fix: issue ssut#234 - manage use of translate.googleapis.com which does not need token
In a perspective to help solving issue #234 I propose a solution that implements a proper way to use translate.googleapis.com as url service.
This url service has following characteristics:
I made a few modifications to mainly deal with these characteristics, preserving the possibility to use standard webapp calls.
The client should use 'translate.googleapis.com' as service url when instanciating Translator() object, adapted code will manage the valuation of client gtx in utils params.
Looking forward to reading your remarks for improvement is needed before final merge.