eric7/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/YandexEngine.py

branch
eric7
changeset 9148
b31f0d894b55
parent 8881
54e42bc2437a
equal deleted inserted replaced
9147:bbf3af40c223 9148:b31f0d894b55
26 26
27 def __init__(self, plugin, parent=None): 27 def __init__(self, plugin, parent=None):
28 """ 28 """
29 Constructor 29 Constructor
30 30
31 @param plugin reference to the plugin object (TranslatorPlugin) 31 @param plugin reference to the plugin object
32 @param parent reference to the parent object (QObject) 32 @type TranslatorPlugin
33 @param parent reference to the parent object
34 @type QObject
33 """ 35 """
34 super().__init__(plugin, parent) 36 super().__init__(plugin, parent)
35 37
36 self.__errors = { 38 self.__errors = {
37 401: self.tr("Yandex: Invalid API key."), 39 401: self.tr("Yandex: Invalid API key."),
49 51
50 def engineName(self): 52 def engineName(self):
51 """ 53 """
52 Public method to return the name of the engine. 54 Public method to return the name of the engine.
53 55
54 @return engine name (string) 56 @return engine name
57 @rtype str
55 """ 58 """
56 return "yandex" 59 return "yandex"
57 60
58 def supportedLanguages(self): 61 def supportedLanguages(self):
59 """ 62 """
60 Public method to get the supported languages. 63 Public method to get the supported languages.
61 64
62 @return list of supported language codes (list of string) 65 @return list of supported language codes
66 @rtype list of str
63 """ 67 """
64 return ["ar", "be", "bg", "bs", "ca", "cs", "da", "de", "el", "en", 68 return ["ar", "be", "bg", "bs", "ca", "cs", "da", "de", "el", "en",
65 "es", "et", "fi", "fr", "ga", "gl", "hi", "hr", "hu", "id", 69 "es", "et", "fi", "fr", "ga", "gl", "hi", "hr", "hu", "id",
66 "is", "it", "iw", "ja", "ka", "ko", "lt", "lv", "mk", "mt", 70 "is", "it", "iw", "ja", "ka", "ko", "lt", "lv", "mk", "mt",
67 "nl", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sq", "sr", 71 "nl", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sq", "sr",
72 translationLanguage): 76 translationLanguage):
73 """ 77 """
74 Public method to translate the given text. 78 Public method to translate the given text.
75 79
76 @param requestObject reference to the request object 80 @param requestObject reference to the request object
77 (TranslatorRequest) 81 @type TranslatorRequest
78 @param text text to be translated (string) 82 @param text text to be translated
79 @param originalLanguage language code of the original (string) 83 @type str
80 @param translationLanguage language code of the translation (string) 84 @param originalLanguage language code of the original
81 @return tuple of translated text (string) and flag indicating 85 @type str
82 success (boolean) 86 @param translationLanguage language code of the translation
87 @type str
88 @return tuple of translated text and flag indicating success
89 @rtype tuple of (str, bool)
83 """ 90 """
84 if len(text) > self.TranslatorLimit: 91 if len(text) > self.TranslatorLimit:
85 return ( 92 return (
86 self.tr("Yandex: Only texts up to {0} characters are allowed.") 93 self.tr("Yandex: Only texts up to {0} characters are allowed.")
87 .format(self.TranslatorLimit), 94 .format(self.TranslatorLimit),

eric ide

mercurial