Skip to content

wronglink/mstranslator

Repository files navigation

mstranslator: Microsoft Translator API wrapper

Travis-ci: continuous integration status. PyPI version

Installation

Install with pip:

$ pip install mstranslator

Usage

1. Subscribe to the Translator API

To access Translator API you need a Microsoft Azure account. Note that subscriptions, up to 2 million characters a month, are free. Translating more than 2 million characters per month requires a payment.

2. Add Translator subscription to your Azure account

  1. Select the + New -> Intelligence + analytics -> Cognitive Services APIs.
  2. Select the API Type option.
  3. Select either Text Translation or Speech Translation.Select the pricing tier that fits your needs.
  4. Fill out the rest of the form, and press the Create button. You are now subscribed to Microsoft Translator.
  5. Now retrieve your subscription key for authentication. You can find it in All Resources -> Keys option.

That's all. Now you have a Subscription Key and can use Microsoft Translator API.

Example Usage:

>>> from mstranslator import Translator
>>> translator = Translator('<Subscription Key>')
>>> print(translator.translate('Привет, мир!', lang_from='ru', lang_to='en'))
Hello World!

Testing

To run tests you need to set TEST_MSTRANSLATOR_SUBSCRIPTION_KEY environment variable and install tox package. After that run shell command:

$ tox

About

Microsoft Translator Api wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages