Skip to content

Commit 1e48d85

Browse files
WIP
1 parent 280294e commit 1e48d85

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

core/CAIAssistant.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _extractParts(self, text):
3939
text = '\n' + text + '\n' # hack to make it work
4040
tmp = [x for x in text.split('\n@')]
4141
# split into parts by :
42-
tmp = [tuple(y.strip('\n" \t\r\'{}') for y in x.split(':', maxsplit=1)) for x in tmp]
42+
tmp = [tuple(y.strip('\n" \t\r\'`{}') for y in x.split(':', maxsplit=1)) for x in tmp]
4343
# remove empty parts
4444
tmp = [x for x in tmp if (len(x) == 2) and (len(x[0]) > 0) and (len(x[1]) > 0)]
4545
return {k: v for k, v in tmp}
@@ -71,11 +71,11 @@ def translate(self, text, fastTranslation, language):
7171
}
7272
)
7373
flags = res['Flags']
74-
totalIssues = sum([int(v) for k, v in flags.items()])
74+
totalIssues = sum([int(v) for v in flags.values()])
7575
if totalIssues < 2:
7676
yield res['Translation']
7777
return # all ok, no need to run deep translation
78-
yield res['Translation'] + '\n\n\n' + res.get('Notification', '')
78+
yield res['Translation'], res.get('Notification', '')
7979

8080
# run deep translation
8181
inputLanguage = res.get('Input language', 'unknown')

core/worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _fullTranslate(self, text, fastTranslation, language):
7474
fastTranslation=fastTranslation,
7575
language=language['name']
7676
)
77-
for translatedText in translationProcess:
78-
yield translatedText
77+
for translation in translationProcess:
78+
yield translation
7979
continue
8080
return

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ def fastTranslated(self, text):
119119
return
120120

121121
def fullTranslated(self, text):
122+
notification = None
123+
if isinstance(text, tuple):
124+
text, notification = text
125+
122126
self._fullOutputText.delete("1.0", tk.END)
123127
self._fullOutputText.insert(tk.END, text)
128+
129+
if notification is not None:
130+
self._fullOutputText.insert(tk.END, "\n----------------\n" + notification)
124131
return
125132

126133
def error(self, e):

0 commit comments

Comments
 (0)