Install with pip:
$ pip install mstranslator
Subscribe to the Microsoft Translator dataset on Azure Marketplace. Note that subscriptions, up to 2 million characters a month, are free. Translating more than 2 million characters per month requires a payment.
Register an application here. As the redirect field is not used but it's marked as required you may enter any URI to pass validation.
That's all. Now you have a Client ID and Client secret.
Example Usage:
>>> from mstranslator import Translator
>>> translator = Translator('<Client ID>', '<Client secret>')
>>> print(translator.translate('Привет, мир!', lang_from='ru', lang_to='en'))
Hello World!
To run tests you need to set TEST_MSTRANSLATOR_CLIENT_ID
and TEST_MSTRANSLATOR_CLIENT_SECRET
environment variables
and install tox package. After that run shell command:
$ tox