Git Product home page Git Product logo

microsoft-translator-python-api's Introduction

Microsoft Translator V2 -- Python API

Version: 0.7
Web:http://fulfil.io/
keywords:Microsoft Translator
Copyright: Fulfil.IO, Openlabs Technologies & Consulting (P) LTD
license:BSD
https://secure.travis-ci.org/fulfilio/Microsoft-Translator-Python-API.png?branch=master https://coveralls.io/repos/fulfilio/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.

Installing

pip install microsofttranslator

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>')
>>> translator.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 translator.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>')
>>> translator.detect_language('hello')
u'en'

Bugs and Development on Github

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

microsoft-translator-python-api's People

Contributors

aroraumang avatar dhpollack avatar mbi avatar mromaine avatar mwoodward avatar nijel avatar sharoonthomas avatar tarunbhardwaj avatar torcellite avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.