src/eric7/Plugins/UiExtensionPlugins/Translator/TranslatorEngines/__init__.py

Sat, 31 Dec 2022 16:23:21 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Dec 2022 16:23:21 +0100
branch
eric7
changeset 9653
e67609152c5e
parent 9495
28ab5f487f71
child 9774
c7b712056146
permissions
-rw-r--r--

Updated copyright for 2023.

6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9495
diff changeset
3 # Copyright (c) 2014 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Package containing the various translation engines.
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9495
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
10 import contextlib
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
11 import importlib
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
14 from PyQt6.QtCore import QCoreApplication
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
15 from PyQt6.QtGui import QIcon
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
18 from eric7.EricWidgets.EricApplication import ericApp
7505
7d3cfeeb5f4f Added breeze style icons for the Translator plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
19
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def supportedEngineNames():
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Module function to get the list of supported translation engines.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
24
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
25 @return names of supported engines
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
26 @rtype list of str
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
28 return [
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
29 "deepl",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
30 "googlev1",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31 "googlev2",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
32 "ibm_watson",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
33 "microsoft",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
34 "mymemory",
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
35 "yandex",
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
36 ]
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def engineDisplayName(name):
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Module function to get a translated name for an engine.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
43 @param name name of a translation engine
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
44 @type str
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
45 @return translated engine name
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
46 @rtype str
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
8237
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
48 return {
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
49 "deepl": QCoreApplication.translate("TranslatorEngines", "DeepL"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
50 "googlev1": QCoreApplication.translate("TranslatorEngines", "Google V.1"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51 "googlev2": QCoreApplication.translate("TranslatorEngines", "Google V.2"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
52 "ibm_watson": QCoreApplication.translate("TranslatorEngines", "IBM Watson"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
53 "microsoft": QCoreApplication.translate("TranslatorEngines", "Microsoft"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
54 "mymemory": QCoreApplication.translate("TranslatorEngines", "MyMemory"),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55 "yandex": QCoreApplication.translate("TranslatorEngines", "Yandex"),
8237
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
56 }.get(
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
57 name,
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
58 QCoreApplication.translate(
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
59 "TranslatorEngines", "Unknow translation service name ({0})"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
60 ).format(name),
8237
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
61 )
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def getTranslationEngine(name, plugin, parent=None):
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Module function to instantiate an engine object for the named service.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
67
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
68 @param name name of the online translation service
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
69 @type str
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
70 @param plugin reference to the plugin object
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
71 @type TranslatorPlugin
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @param parent reference to the parent object
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
73 @type QObject
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
74 @return translation engine
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
75 @rtype TranslatorEngine
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
9495
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
77 engineMapping = {
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
78 "deepl": ".DeepLEngine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
79 "googlev1": ".GoogleV1Engine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
80 "googlev2": ".GoogleV2Engine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
81 "ibm_watson": ".IbmWatsonEngine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
82 "microsoft": ".MicrosoftEngine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
83 "mymemory": ".MyMemoryEngine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
84 "yandex": ".YandexEngine",
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
85 }
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
86
9495
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
87 with contextlib.suppress(KeyError):
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
88 mod = importlib.import_module(engineMapping[name], __package__)
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
89 if mod:
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
90 return mod.createEngine(plugin, parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
9495
28ab5f487f71 Changed translation engine imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
92 return None
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 def getEngineIcon(name):
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 Module function to get the icon of the named engine.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
98
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @param name name of the translation engine
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @type str
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @return engine icon
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 @rtype QIcon
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
104 iconSuffix = "dark" if ericApp().usesDarkPalette() else "light"
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 if name in supportedEngineNames():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
106 icon = EricPixmapCache.getIcon(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107 os.path.join(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
108 os.path.dirname(__file__),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109 "..",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 "icons",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111 "engines",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
112 "{0}-{1}".format(name, iconSuffix),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
114 )
7505
7d3cfeeb5f4f Added breeze style icons for the Translator plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
115 if icon.isNull():
7d3cfeeb5f4f Added breeze style icons for the Translator plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
116 # try variant without suffix
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
117 icon = EricPixmapCache.getIcon(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 os.path.join(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119 os.path.dirname(__file__),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
120 "..",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
121 "icons",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
122 "engines",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
123 "{0}".format(name),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
124 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
125 )
7505
7d3cfeeb5f4f Added breeze style icons for the Translator plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
126 return icon
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 else:
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 return QIcon()
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 def getKeyUrl(name):
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 Module function to get an URL to request a user key.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
134
9148
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
135 @param name name of the online translation service
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
136 @type str
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
137 @return key request URL
b31f0d894b55 Translator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9145
diff changeset
138 @rtype str
6018
1c858879d3d0 Added the translator plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
8237
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
140 return {
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
141 "deepl": "https://www.deepl.com/de/pro-api",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
142 "googlev2": "https://console.developers.google.com/",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
143 "ibm_watson": "https://www.ibm.com/watson/services/language-translator/",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
144 "microsoft": "https://portal.azure.com",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
145 "mymemory": "http://mymemory.translated.net/doc/keygen.php",
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
146 "yandex": "http://api.yandex.com/key/form.xml?service=trnsl",
8237
acc1490f822e Applied some more code simplifications suggested by the new Simplify checker (Y116: use dictionary access instead of multiple ifs).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8234
diff changeset
147 }.get(name, "")

eric ide

mercurial