24 |
24 |
25 def __init__(self, plugin, parent=None): |
25 def __init__(self, plugin, parent=None): |
26 """ |
26 """ |
27 Constructor |
27 Constructor |
28 |
28 |
29 @param plugin reference to the plugin object (TranslatorPlugin) |
29 @param plugin reference to the plugin object |
30 @param parent reference to the parent object (QObject) |
30 @type TranslatorPlugin |
|
31 @param parent reference to the parent object |
|
32 @type QObject |
31 """ |
33 """ |
32 super().__init__(plugin, parent) |
34 super().__init__(plugin, parent) |
33 |
35 |
34 QTimer.singleShot(0, self.availableTranslationsLoaded.emit) |
36 QTimer.singleShot(0, self.availableTranslationsLoaded.emit) |
35 |
37 |
36 def engineName(self): |
38 def engineName(self): |
37 """ |
39 """ |
38 Public method to return the name of the engine. |
40 Public method to return the name of the engine. |
39 |
41 |
40 @return engine name (string) |
42 @return engine name |
|
43 @rtype str |
41 """ |
44 """ |
42 return "mymemory" |
45 return "mymemory" |
43 |
46 |
44 def supportedLanguages(self): |
47 def supportedLanguages(self): |
45 """ |
48 """ |
46 Public method to get the supported languages. |
49 Public method to get the supported languages. |
47 |
50 |
48 @return list of supported language codes (list of string) |
51 @return list of supported language codes |
|
52 @rtype list of str |
49 """ |
53 """ |
50 return ["ar", "be", "bg", "bs", "ca", "cs", "da", "de", "el", "en", |
54 return ["ar", "be", "bg", "bs", "ca", "cs", "da", "de", "el", "en", |
51 "es", "et", "fi", "fr", "ga", "gl", "hi", "hr", "hu", "id", |
55 "es", "et", "fi", "fr", "ga", "gl", "hi", "hr", "hu", "id", |
52 "is", "it", "iw", "ja", "ka", "ko", "lt", "lv", "mk", "mt", |
56 "is", "it", "iw", "ja", "ka", "ko", "lt", "lv", "mk", "mt", |
53 "nl", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sq", "sr", |
57 "nl", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sq", "sr", |
58 translationLanguage): |
62 translationLanguage): |
59 """ |
63 """ |
60 Public method to translate the given text. |
64 Public method to translate the given text. |
61 |
65 |
62 @param requestObject reference to the request object |
66 @param requestObject reference to the request object |
63 (TranslatorRequest) |
67 @type TranslatorRequest |
64 @param text text to be translated (string) |
68 @param text text to be translated |
65 @param originalLanguage language code of the original (string) |
69 @type str |
66 @param translationLanguage language code of the translation (string) |
70 @param originalLanguage language code of the original |
67 @return tuple of translated text (string) and flag indicating |
71 @type str |
68 success (boolean) |
72 @param translationLanguage language code of the translation |
|
73 @type str |
|
74 @return tuple of translated text and flag indicating success |
|
75 @rtype tuple of (str, bool) |
69 """ |
76 """ |
70 if len(text) > self.TranslatorLimit: |
77 if len(text) > self.TranslatorLimit: |
71 return ( |
78 return ( |
72 self.tr("MyMemory: Only texts up to {0} characters are" |
79 self.tr("MyMemory: Only texts up to {0} characters are" |
73 " allowed.") |
80 " allowed.") |