'Detect the source text\'s language.'

def detect(self, source, host=None, type_=None):

    if PY2:
        source = source.encode('utf-8')
    if (len(source) < 3):
        raise TranslatorError('Must    provide    a    string    with    at    least    3    characters.')
    data = {'q': source}
    url = u'{url}&sl=auto&tk={tk}'.format(url=self.url, tk=_calculate_tk(source))
    response = self._request(url, host=host, type_=type_, data=data)
    (result, language) = json.loads(response)
    return language
