Plugins/UiExtensionPlugins/Translator/TranslatorEngines/TranslationEngine.py

changeset 6412
d71b094845e7
parent 6411
7fd9b7ecbcfe
child 6645
ad476851d7e0
equal deleted inserted replaced
6411:7fd9b7ecbcfe 6412:d71b094845e7
7 Module implementing the translation engine base class. 7 Module implementing the translation engine base class.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import QObject 12 from PyQt5.QtCore import pyqtSignal, QObject
13 13
14 14
15 class TranslationEngine(QObject): 15 class TranslationEngine(QObject):
16 """ 16 """
17 Class implementing the translation engine base class containing 17 Class implementing the translation engine base class containing
18 default methods. 18 default methods.
19
20 @signal availableTranslationsLoaded() emitted to indicate the availability
21 of the list of supported translation languages
19 """ 22 """
23 availableTranslationsLoaded = pyqtSignal()
24
20 def __init__(self, plugin, parent=None): 25 def __init__(self, plugin, parent=None):
21 """ 26 """
22 Constructor 27 Constructor
23 28
24 @param plugin reference to the plugin object (TranslatorPlugin) 29 @param plugin reference to the plugin object (TranslatorPlugin)
47 def supportedTargetLanguages(self, original): 52 def supportedTargetLanguages(self, original):
48 """ 53 """
49 Public method to get a list of supported target languages for an 54 Public method to get a list of supported target languages for an
50 original language. 55 original language.
51 56
57 Note: The default implementation return the list of supported languages
58 (i.e. the same as those for the source) with the given original
59 removed.
60
52 @param original original language 61 @param original original language
53 @type str 62 @type str
54 @return list of supported target languages for the given original 63 @return list of supported target languages for the given original
55 @rtype None, if function is not supported; list of str otherwise 64 @rtype list of str
56 """ 65 """
57 return None 66 targetLanguages = self.supportedLanguages()[:]
67 try:
68 targetLanguages.remove(original)
69 except ValueError:
70 # original is not in the list of target languages
71 pass
72
73 return targetLanguages
58 74
59 def hasTTS(self): 75 def hasTTS(self):
60 """ 76 """
61 Public method indicating the Text-to-Speech capability. 77 Public method indicating the Text-to-Speech capability.
62 78

eric ide

mercurial