Plugins/UiExtensionPlugins/Translator/TranslatorEngines/TranslationEngine.py

changeset 6018
1c858879d3d0
child 6048
82ad8ec9548c
equal deleted inserted replaced
6017:dab01678626d 6018:1c858879d3d0
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the translation engine base class.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import QObject
13
14
15 class TranslationEngine(QObject):
16 """
17 Class implementing the translation engine base class containing
18 default methods.
19 """
20 def __init__(self, plugin, parent=None):
21 """
22 Constructor
23
24 @param plugin reference to the plugin object (TranslatorPlugin)
25 @param parent reference to the parent object (QObject)
26 """
27 super(TranslationEngine, self).__init__(parent)
28
29 self.plugin = plugin
30
31 def engineName(self):
32 """
33 Public method to get the name of the engine.
34
35 @return engine name (string)
36 """
37 return ""
38
39 def supportedLanguages(self):
40 """
41 Public method to get the supported languages.
42
43 @return list of supported language codes (list of string)
44 """
45 return []
46
47 def hasTTS(self):
48 """
49 Public method indicating the Text-to-Speech capability.
50
51 @return flag indicating the Text-to-Speech capability (boolean)
52 """
53 return False
54
55 def getTextToSpeechData(self, requestObject, text, language):
56 """
57 Public method to pronounce the given text.
58
59 @param requestObject reference to the request object
60 (TranslatorRequest)
61 @param text text to be pronounced (string)
62 @param language language code of the text (string)
63 @return tuple with pronounce data (QByteArray) or error string (string)
64 and success flag (boolean)
65 """
66 return self.tr("No pronounce data available"), False
67
68 def getTranslation(self, requestObject, text, originalLanguage,
69 translationLanguage):
70 """
71 Public method to translate the given text.
72
73 @param requestObject reference to the request object
74 (TranslatorRequest)
75 @param text text to be translated (string)
76 @param originalLanguage language code of the original (string)
77 @param translationLanguage language code of the translation (string)
78 @return tuple of translated text (string) and flag indicating
79 success (boolean)
80 """
81 return self.tr("No translation available"), False

eric ide

mercurial