eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py

changeset 8237
acc1490f822e
parent 8234
fcb6b4b96274
--- a/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py	Wed Apr 14 17:34:27 2021 +0200
+++ b/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py	Wed Apr 14 17:39:44 2021 +0200
@@ -34,28 +34,31 @@
     @param name name of a translation engine (string)
     @return translated engine name (string)
     """
-    if name == "googlev1":
-        return QCoreApplication.translate("TranslatorEngines", "Google V.1")
-    elif name == "mymemory":
-        return QCoreApplication.translate("TranslatorEngines", "MyMemory")
-    elif name == "glosbe":
-        return QCoreApplication.translate("TranslatorEngines", "Glosbe")
-    elif name == "promt":
-        return QCoreApplication.translate("TranslatorEngines", "PROMT")
-    elif name == "yandex":
-        return QCoreApplication.translate("TranslatorEngines", "Yandex")
-    elif name == "googlev2":
-        return QCoreApplication.translate("TranslatorEngines", "Google V.2")
-    elif name == "microsoft":
-        return QCoreApplication.translate("TranslatorEngines", "Microsoft")
-    elif name == "deepl":
-        return QCoreApplication.translate("TranslatorEngines", "DeepL Pro")
-    elif name == "ibm_watson":
-        return QCoreApplication.translate("TranslatorEngines", "IBM Watson")
-    else:
-        return QCoreApplication.translate(
+    return {
+        "googlev1":
+            QCoreApplication.translate("TranslatorEngines", "Google V.1"),
+        "googlev2":
+            QCoreApplication.translate("TranslatorEngines", "Google V.2"),
+        "mymemory":
+            QCoreApplication.translate("TranslatorEngines", "MyMemory"),
+        "glosbe":
+            QCoreApplication.translate("TranslatorEngines", "Glosbe"),
+        "promt":
+            QCoreApplication.translate("TranslatorEngines", "PROMT"),
+        "yandex":
+            QCoreApplication.translate("TranslatorEngines", "Yandex"),
+        "microsoft":
+            QCoreApplication.translate("TranslatorEngines", "Microsoft"),
+        "deepl":
+            QCoreApplication.translate("TranslatorEngines", "DeepL Pro"),
+        "ibm_watson":
+            QCoreApplication.translate("TranslatorEngines", "IBM Watson")
+    }.get(
+        name,
+        QCoreApplication.translate(
             "TranslatorEngines", "Unknow translation service name ({0})"
         ).format(name)
+    )
 
 
 def getTranslationEngine(name, plugin, parent=None):
@@ -130,17 +133,17 @@
     @param name name of the online translation service (string)
     @return key request URL (string)
     """
-    if name == "mymemory":
-        return "http://mymemory.translated.net/doc/keygen.php"
-    elif name == "yandex":
-        return "http://api.yandex.com/key/form.xml?service=trnsl"
-    elif name == "googlev2":
-        return "https://console.developers.google.com/"
-    elif name == "microsoft":
-        return "https://portal.azure.com"
-    elif name == "ibm_watson":
-        return "https://www.ibm.com/watson/services/language-translator/"
-    elif name == "deepl":
-        return "https://www.deepl.com/pro-registration.html"
-    else:
-        return ""
+    return {
+        "googlev2":
+            "https://console.developers.google.com/",
+        "mymemory":
+            "http://mymemory.translated.net/doc/keygen.php",
+        "yandex":
+            "http://api.yandex.com/key/form.xml?service=trnsl",
+        "microsoft":
+            "https://portal.azure.com",
+        "deepl":
+            "https://www.deepl.com/pro-registration.html",
+        "ibm_watson":
+            "https://www.ibm.com/watson/services/language-translator/"
+    }.get(name, "")

eric ide

mercurial