32 Module function to get a translated name for an engine. |
32 Module function to get a translated name for an engine. |
33 |
33 |
34 @param name name of a translation engine (string) |
34 @param name name of a translation engine (string) |
35 @return translated engine name (string) |
35 @return translated engine name (string) |
36 """ |
36 """ |
37 if name == "googlev1": |
37 return { |
38 return QCoreApplication.translate("TranslatorEngines", "Google V.1") |
38 "googlev1": |
39 elif name == "mymemory": |
39 QCoreApplication.translate("TranslatorEngines", "Google V.1"), |
40 return QCoreApplication.translate("TranslatorEngines", "MyMemory") |
40 "googlev2": |
41 elif name == "glosbe": |
41 QCoreApplication.translate("TranslatorEngines", "Google V.2"), |
42 return QCoreApplication.translate("TranslatorEngines", "Glosbe") |
42 "mymemory": |
43 elif name == "promt": |
43 QCoreApplication.translate("TranslatorEngines", "MyMemory"), |
44 return QCoreApplication.translate("TranslatorEngines", "PROMT") |
44 "glosbe": |
45 elif name == "yandex": |
45 QCoreApplication.translate("TranslatorEngines", "Glosbe"), |
46 return QCoreApplication.translate("TranslatorEngines", "Yandex") |
46 "promt": |
47 elif name == "googlev2": |
47 QCoreApplication.translate("TranslatorEngines", "PROMT"), |
48 return QCoreApplication.translate("TranslatorEngines", "Google V.2") |
48 "yandex": |
49 elif name == "microsoft": |
49 QCoreApplication.translate("TranslatorEngines", "Yandex"), |
50 return QCoreApplication.translate("TranslatorEngines", "Microsoft") |
50 "microsoft": |
51 elif name == "deepl": |
51 QCoreApplication.translate("TranslatorEngines", "Microsoft"), |
52 return QCoreApplication.translate("TranslatorEngines", "DeepL Pro") |
52 "deepl": |
53 elif name == "ibm_watson": |
53 QCoreApplication.translate("TranslatorEngines", "DeepL Pro"), |
54 return QCoreApplication.translate("TranslatorEngines", "IBM Watson") |
54 "ibm_watson": |
55 else: |
55 QCoreApplication.translate("TranslatorEngines", "IBM Watson") |
56 return QCoreApplication.translate( |
56 }.get( |
|
57 name, |
|
58 QCoreApplication.translate( |
57 "TranslatorEngines", "Unknow translation service name ({0})" |
59 "TranslatorEngines", "Unknow translation service name ({0})" |
58 ).format(name) |
60 ).format(name) |
|
61 ) |
59 |
62 |
60 |
63 |
61 def getTranslationEngine(name, plugin, parent=None): |
64 def getTranslationEngine(name, plugin, parent=None): |
62 """ |
65 """ |
63 Module function to instantiate an engine object for the named service. |
66 Module function to instantiate an engine object for the named service. |
128 Module function to get an URL to request a user key. |
131 Module function to get an URL to request a user key. |
129 |
132 |
130 @param name name of the online translation service (string) |
133 @param name name of the online translation service (string) |
131 @return key request URL (string) |
134 @return key request URL (string) |
132 """ |
135 """ |
133 if name == "mymemory": |
136 return { |
134 return "http://mymemory.translated.net/doc/keygen.php" |
137 "googlev2": |
135 elif name == "yandex": |
138 "https://console.developers.google.com/", |
136 return "http://api.yandex.com/key/form.xml?service=trnsl" |
139 "mymemory": |
137 elif name == "googlev2": |
140 "http://mymemory.translated.net/doc/keygen.php", |
138 return "https://console.developers.google.com/" |
141 "yandex": |
139 elif name == "microsoft": |
142 "http://api.yandex.com/key/form.xml?service=trnsl", |
140 return "https://portal.azure.com" |
143 "microsoft": |
141 elif name == "ibm_watson": |
144 "https://portal.azure.com", |
142 return "https://www.ibm.com/watson/services/language-translator/" |
145 "deepl": |
143 elif name == "deepl": |
146 "https://www.deepl.com/pro-registration.html", |
144 return "https://www.deepl.com/pro-registration.html" |
147 "ibm_watson": |
145 else: |
148 "https://www.ibm.com/watson/services/language-translator/" |
146 return "" |
149 }.get(name, "") |