Skip to content

Commit d25f436

Browse files
author
Sharoon Thomas
committed
Release version 0.7
1 parent b4b7843 commit d25f436

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
Version 0.7
5+
-----------
6+
* Add support for language detection and finding supported languages (Thanks
7+
to Karthik Balakrishnan)
8+
49
Version 0.6
510
-----------
611
* Handle token expiry (Thanks to @ScreenDriver)

README.rst

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Microsoft Translator V2 -- Python API
22
=====================================
33

4-
:Version: 0.6
4+
:Version: 0.7
55
:Web: http://openlabs.co.in/
66
:keywords: Microsoft Translator
77
:copyright: Openlabs Technologies & Consulting (P) LTD
@@ -43,6 +43,50 @@ optional.
4343

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

46+
Features
47+
--------
48+
49+
Translation
50+
+++++++++++
51+
52+
::
53+
54+
>>> from microsofttranslator import Translator
55+
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
56+
>>> print translator.translate("Hello", "pt")
57+
"Olá"
58+
59+
Translate multiple words at once
60+
++++++++++++++++++++++++++++++++
61+
62+
::
63+
64+
>>> from microsofttranslator import Translator
65+
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
66+
>>> client.translate_array(['apple', 'orange'], 'pt')
67+
[{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]}]
68+
69+
Get supported languages
70+
+++++++++++++++++++++++
71+
72+
::
73+
74+
>>> from microsofttranslator import Translator
75+
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
76+
>>> print client.get_languages()
77+
[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']
78+
79+
Detect Language
80+
+++++++++++++++
81+
82+
::
83+
84+
>>> from microsofttranslator import Translator
85+
>>> translator = Translator('<Your Client ID>', '<Your Client Secret>')
86+
>>> client.detect_language('hello')
87+
u'en'
88+
89+
4690
Bugs and Development on Github
4791
------------------------------
4892

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
setup(
3333
name="microsofttranslator",
34-
version="0.6",
34+
version="0.7",
3535
packages=[
3636
'microsofttranslator',
3737
],

test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
class TestTranslator(unittest.TestCase):
2020

2121
def test_translate(self):
22+
client = Translator(client_id, client_secret, debug=True)
23+
self.assertEqual(
24+
client.translate("hello", "pt"), u'Ol\xe1'
25+
)
26+
27+
def test_translate_array(self):
2228
client = Translator(client_id, client_secret, debug=True)
2329
self.assertEqual(client.translate("hello", "pt"), u'Ol\xe1')
2430

0 commit comments

Comments
 (0)