Skip to main content

Microsoft Translator V2 - Python API

Project description

Version:
0.7
Web:

http://openlabs.co.in/

keywords:

Microsoft Translator

license:

BSD

https://secure.travis-ci.org/openlabs/Microsoft-Translator-Python-API.png?branch=master https://coveralls.io/repos/openlabs/Microsoft-Translator-Python-API/badge.png?branch=master

This python API implements the Microsoft Translator services which can be used in web or client applications to perform language translation operations. The services support users who are not familiar with the default language of a page or application, or those desiring to communicate with people of a different language group.

Example Usage:

>>> from microsofttranslator import Translator
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
>>> print translator.translate("Hello", "pt")
"Olá"

Registering your application

To register your application with Azure DataMarket, visit https://datamarket.azure.com/developer/applications/ using the LiveID credentials from step 1, and click on “Register”. In the “Register your application” dialog box, you can define your own Client ID and Name. The redirect URI is not used for the Microsoft Translator API. However, the redirect URI field is a mandatory field, and you must provide a URI to obtain the access code. A description is optional.

Take a note of the client ID and the client secret value.

Features

Translation

>>> from microsofttranslator import Translator
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
>>> print translator.translate("Hello", "pt")
"Olá"

Translate multiple words at once

>>> from microsofttranslator import Translator
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
>>> client.translate_array(['apple', 'orange'], 'pt')
[{u'TranslatedText': u'Apple', u'From': u'en', u'OriginalTextSentenceLengths': [5], u'TranslatedTextSentenceLengths': [5]}, {u'TranslatedText': u'laranja', u'From': u'en', u'OriginalTextSentenceLengths': [6], u'TranslatedTextSentenceLengths': [7]}]

Get supported languages

>>> from microsofttranslator import Translator
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
>>> print client.get_languages()
[u'ar', u'bg', u'ca', u'zh-CHS', u'zh-CHT', u'cs', u'da', u'nl', u'en', u'et', u'fi', u'fr', u'de', u'el', u'ht', u'he', u'hi', u'mww', u'hu', u'id', u'it', u'ja', u'tlh', u'tlh-Qaak', u'ko', u'lv', u'lt', u'ms', u'mt', u'no', u'fa', u'pl', u'pt', u'ro', u'ru', u'sk', u'sl', u'es', u'sv', u'th', u'tr', u'uk', u'ur', u'vi', u'cy']

Detect Language

>>> from microsofttranslator import Translator
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
>>> client.detect_language('hello')
u'en'

Bugs and Development on Github

https://github.com/openlabs/Microsoft-Translator-Python-API

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microsofttranslator-0.7.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file microsofttranslator-0.7.tar.gz.

File metadata

File hashes

Hashes for microsofttranslator-0.7.tar.gz
Algorithm Hash digest
SHA256 5769ba4a82a717e07ee18b7b7be9a89811389c898e2470e6d78722fba40d36dd
MD5 fd8c4976b6be27843aa1d7fe32c1bf3c
BLAKE2b-256 5c4e2bc27db9ce0d3043e799b104eff9d90eb748db4d9d3979dc2c67f068f28a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page