Commits

Branko Vukelic committed d0725be

Fixed #3: Language auto-detection with optional tfrom

Comments (0)

Files changed (1)

mstranslator/endpoints/translate.py

 class TranslateEndpoint(GetEndpoint):
     endpoint = 'Translate'
 
-    def __init__(self, text, tfrom, to):
+    def __init__(self, text, to, tfrom=None):
 
-        if tfrom not in LANGUAGE_CODES or to not in LANGUAGE_CODES:
+        if tfrom and tfrom not in LANGUAGE_CODES or to not in LANGUAGE_CODES:
             raise ValueError('Invalid language codes')
 
         self.convert_kwargs(locals())