1. Monwara LLC
  2. Untitled project
  3. PyMSTranslator

Source

PyMSTranslator / mstranslator / endpoints / translate.py

Branko Vukelic cdd551c 




Branko Vukelic d0725be 
Branko Vukelic cdd551c 
Branko Vukelic d0725be 
Branko Vukelic cdd551c 



Branko Vukelic a8adbc4 

from base import GetEndpoint, CONTENT, LANGUAGE_CODES

class TranslateEndpoint(GetEndpoint):
    endpoint = 'Translate'

    def __init__(self, text, to, tfrom=None):

        if tfrom and tfrom not in LANGUAGE_CODES or to not in LANGUAGE_CODES:
            raise ValueError('Invalid language codes')

        self.convert_kwargs(locals())

    def process_response(self, resp):
        root = self.parse_xml(resp)
        return root.text