2015-07-17 13:52:32 +02:00
|
|
|
class Translated(object):
|
2015-06-06 07:44:15 +02:00
|
|
|
"""
|
|
|
|
The Translated object, which contains Google Translator's result.
|
|
|
|
|
|
|
|
:param src: source langauge (default: auto)
|
|
|
|
:param dest: destination language (default: en)
|
|
|
|
:param origin: original text
|
|
|
|
:param text: translated text
|
|
|
|
:param pronunciation: the pronunciation provided by Google Translator
|
|
|
|
"""
|
|
|
|
def __init__(self, src, dest, origin, text, pronunciation):
|
|
|
|
self.src = src
|
|
|
|
self.dest = dest
|
|
|
|
self.origin = origin
|
|
|
|
self.text = text
|
|
|
|
self.pronunciation = pronunciation
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __str__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return self.__unicode__()
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __unicode__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return u'<Translated src={src} dest={dest} text={text} pronunciation={pronunciation}>'.format(
|
|
|
|
src=self.src, dest=self.dest, text=self.text, pronunciation=self.pronunciation)
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
|
2015-07-17 13:52:32 +02:00
|
|
|
class Detected(object):
|
2015-06-06 07:44:15 +02:00
|
|
|
"""
|
|
|
|
The detected object, which contains Google Translator's langauge detection result.
|
|
|
|
|
|
|
|
:param lang: detected language
|
|
|
|
:param confidence: the confidence of detection (0.00 to 1.00)
|
|
|
|
"""
|
|
|
|
def __init__(self, lang, confidence):
|
|
|
|
self.lang = lang
|
|
|
|
self.confidence = confidence
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __str__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return self.__unicode__()
|
|
|
|
|
2017-03-10 11:19:46 +01:00
|
|
|
def __unicode__(self): # pragma: nocover
|
2015-06-06 07:44:15 +02:00
|
|
|
return u'<Detected lang={lang} confidence={confidence}>'.format(
|
2017-03-10 11:19:46 +01:00
|
|
|
lang=self.lang, confidence=self.confidence)
|