Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit cc0b3b7

Browse files
[translators] v3
1 parent 958eff2 commit cc0b3b7

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

translators/__init__.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from albert import *
1313
import translators as ts
1414

15-
md_iid = '2.3'
16-
md_version = "1.8"
15+
md_iid = "3.0"
16+
md_version = "2.0"
1717
md_name = "Translator"
1818
md_description = "Translate sentences using 'translators' package"
1919
md_license = "MIT"
@@ -26,11 +26,8 @@ class Plugin(PluginInstance, TriggerQueryHandler):
2626

2727
def __init__(self):
2828
PluginInstance.__init__(self)
29-
TriggerQueryHandler.__init__(
30-
self, self.id, self.name, self.description,
31-
synopsis="[[from] to] text",
32-
defaultTrigger='tr '
33-
)
29+
TriggerQueryHandler.__init__(self)
30+
3431
self.iconUrls = [f"file:{Path(__file__).parent}/google_translate.png"]
3532

3633
self._translator = self.readConfig('translator', str)
@@ -69,6 +66,9 @@ def lang(self, value):
6966
self._lang = value
7067
self.writeConfig('lang', value)
7168

69+
def defaultTrigger(self):
70+
return 'tr '
71+
7272
def configWidget(self):
7373
return [
7474
{
@@ -88,6 +88,9 @@ def configWidget(self):
8888
}
8989
]
9090

91+
def synopsis(self, s):
92+
return "[[from] to] text"
93+
9194
def handleTriggerQuery(self, query):
9295
stripped = query.string.strip()
9396
if stripped:
@@ -126,7 +129,7 @@ def handleTriggerQuery(self, query):
126129
)
127130

128131
query.add(StandardItem(
129-
id=self.id,
132+
id=self.id(),
130133
text=translation,
131134
subtext=f"{src.upper()} > {dst.upper()}",
132135
iconUrls=self.iconUrls,
@@ -136,7 +139,7 @@ def handleTriggerQuery(self, query):
136139
except Exception as e:
137140

138141
query.add(StandardItem(
139-
id=self.id,
142+
id=self.id(),
140143
text="Error",
141144
subtext=str(e),
142145
iconUrls=self.iconUrls

0 commit comments

Comments
 (0)