Skip to content
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

feat(rpc)!: add support for Google's new RPC-based request mechanism #255

Closed
wants to merge 11 commits into from

Conversation

ssut
Copy link
Owner

@ssut ssut commented Dec 9, 2020

🎉 Happy to announce the long-awaited release of such stable Googletrans that responds to the new Google's RPC-based request mechanism. This introduces possibly backward-incompatible API changes and have the following changes:

I'm planning to publish this PR as Release Candidate to PyPI starting with v4.0.0-rc1. As such use this at your own risk.

>>> __import__('googletrans').Translator().translate('안녕하세요. 반가워요!', dest='zh-cn').__dict__()
{'src': 'ko', 'dest': 'zh-cn', 'origin': '안녕하세요. 반가워요!', 'text': '你好。很高兴见到你!', 'pronunciation': 'Nǐ hǎo. Hěn gāoxìng jiàn dào nǐ!', 'extra_data': {'confidence': None, 'parts': [<googletrans.models.TranslatedPart object at 0x106302e80>, <googletrans.models.TranslatedPart object at 0x106302670>], 'origin_pronunciation': 'annyeonghaseyo. bangawoyo!', 'parsed': [['annyeonghaseyo. bangawoyo!', None, 'ko', [[[0, [[[None, 6]], [True]]], [1, [[[None, 7], [7, 12]], [False, True]]]], 12]], [[[None, 'Nǐ hǎo. Hěn gāoxìng jiàn dào nǐ!', None, None, None, [['你好。', ['你好。', '您好。', '你好']], ['很高兴见到你!', ['很高兴见到你!', '很高兴认识你!'], True]]]], 'zh-cn', 1, 'auto'], 'ko']}, 'parts': [{'text': '你好。', 'candidates': ['你好。', '您好。', '你好']}, {'text': '很高兴见到你!', 'candidates': ['很高兴见到你!', '很高兴认识你!']}]}
>>> __import__('googletrans').Translator().translate('안녕하세요. 반가워요!', dest='en').__dict__()
{'src': 'ko', 'dest': 'en', 'origin': '안녕하세요. 반가워요!', 'text': 'Hello. Nice to meet you!', 'pronunciation': None, 'extra_data': {'confidence': None, 'parts': [<googletrans.models.TranslatedPart object at 0x10632e8b0>, <googletrans.models.TranslatedPart object at 0x10632e0d0>], 'origin_pronunciation': 'annyeonghaseyo. bangawoyo!', 'parsed': [['annyeonghaseyo. bangawoyo!', None, 'ko', [[[0, [[[None, 6]], [True]]], [1, [[[None, 7], [7, 12]], [False, True]]]], 12]], [[[None, None, None, True, None, [['Hello.', ['Hello.', 'Hi.', 'Good morning.']], ['Nice to meet you!', ['Nice to meet you!'], True]]]], 'en', 1, 'auto'], 'ko']}, 'parts': [{'text': 'Hello.', 'candidates': ['Hello.', 'Hi.', 'Good morning.']}, {'text': 'Nice to meet you!', 'candidates': ['Nice to meet you!']}]}

alainrouillon and others added 9 commits December 2, 2020 22:13
* fix: issue #234 - extend service url to direct api

fix: issue #234 - manage use of translate.googleapis.com which does not need token

* fix: issue #234 - extend use of direct api

fix: issue #234 - manage use of translate.googleapis.com which does not need token

* fix: issue #234 - extend use of direct api

fix: issue #234 - manage use of translate.googleapis.com which does not need token

* fix: issue #234 - extend use of direct api

fix: issue #234 - manage use of translate.googleapis.com which does not need token

* fix: issue #234 - extend use of direct api

fix: issue #234 - manage use of translate.googleapis.com which does not need token
@coveralls
Copy link

coveralls commented Dec 9, 2020

Coverage Status

Coverage decreased (-36.6%) to 54.667% when pulling 0255662 on feature/rpc into 4f7c079 on master.

@jaklinger
Copy link

Thanks for introducing this, I've not had any issues using the new non-bulk translate method on OSX10.15.6 or AmazonLinux1/2, python 3.6-3.8.

It seems however that the bulk operations are more fiddly with the new RPC mechanism. I tried playing around with the raw requests to see whether this would be possible, but with no luck. Have you had any insights into this?

@stale
Copy link

stale bot commented Feb 8, 2021

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.

@stale stale bot added the wontfix label Feb 8, 2021
}
r = self.client.post(url, params=params, data=data)

if r.status_code != 200 and self.raise_Exception:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be self.raise_exception instead of self.raise_Exception

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stale stale bot removed the wontfix label Feb 9, 2021
@ArtanisTheOne
Copy link

ArtanisTheOne commented Mar 5, 2021

Any timetable on when this can be finished or what needs to be done? Also, would detecting languages still be possible with this version of the module?

@ArtanisTheOne
Copy link

@ssut

@ArtanisTheOne
Copy link

Difference between translate_legacy and translate?

@stale
Copy link

stale bot commented May 12, 2021

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.

@stale stale bot added the wontfix label May 12, 2021
@stale stale bot closed this May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error in result (AttributeError: 'NoneType' object has no attribute 'group')
8 participants