diff --git a/docs/source/platypush/responses/translate.rst b/docs/source/platypush/responses/translate.rst deleted file mode 100644 index 9bda8aa2a..000000000 --- a/docs/source/platypush/responses/translate.rst +++ /dev/null @@ -1,5 +0,0 @@ -``translate`` -======================================== - -.. automodule:: platypush.message.response.translate - :members: diff --git a/docs/source/responses.rst b/docs/source/responses.rst index fff5bcdc5..f9bd22585 100644 --- a/docs/source/responses.rst +++ b/docs/source/responses.rst @@ -9,4 +9,3 @@ Responses platypush/responses/google.drive.rst platypush/responses/printer.cups.rst platypush/responses/tensorflow.rst - platypush/responses/translate.rst diff --git a/platypush/message/response/translate.py b/platypush/message/response/translate.py deleted file mode 100644 index 8a272f556..000000000 --- a/platypush/message/response/translate.py +++ /dev/null @@ -1,18 +0,0 @@ -from platypush.message.response import Response - - -class TranslateResponse(Response): - def __init__(self, - translated_text: str, - source_text: str, - detected_source_language: str, - *args, - **kwargs): - super().__init__(*args, output={ - 'translated_text': translated_text, - 'source_text': source_text, - 'detected_source_language': detected_source_language, - }, **kwargs) - - -# vim:sw=4:ts=4:et: diff --git a/platypush/plugins/google/translate/__init__.py b/platypush/plugins/google/translate/__init__.py index 3fbd0fd5b..5d588cf0d 100644 --- a/platypush/plugins/google/translate/__init__.py +++ b/platypush/plugins/google/translate/__init__.py @@ -3,7 +3,6 @@ from typing import Optional, List from google.cloud import translate_v2 as translate -from platypush.message.response.translate import TranslateResponse from platypush.plugins import action, Plugin @@ -98,7 +97,7 @@ class GoogleTranslatePlugin(Plugin): target_language: Optional[str] = None, source_language: Optional[str] = None, format: Optional[str] = None, - ) -> TranslateResponse: + ) -> dict: """ Translate a piece of text or HTML. @@ -106,7 +105,16 @@ class GoogleTranslatePlugin(Plugin): :param target_language: target_language override. :param source_language: source_language (default: auto-detect). :param format: Input format (available formats: ``text``, ``html``). - :return: :class:`platypush.message.response.translate.TranslateResponse`. + :return: dict + + .. code-block:: json + + { + "translated_text": "Translated text", + "source_text": "Source text", + "detected_source_language": "Detected source language" + } + """ target_language = target_language or self.target_language args = {} @@ -127,11 +135,11 @@ class GoogleTranslatePlugin(Plugin): else: result['translatedText'] += ' ' + response['translatedText'] - return TranslateResponse( - translated_text=result.get('translatedText'), - source_text=text, - detected_source_language=result.get('detectedSourceLanguage'), - ) + return { + 'translated_text': result.get('translatedText'), + 'source_text': text, + 'detected_source_language': result.get('detectedSourceLanguage'), + } # vim:sw=4:ts=4:et: