Skip to content

Commit e36e6fd

Browse files
fix empty translation
1 parent 2a7ba3d commit e36e6fd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

core/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _fastTranslate(self, text, languageCode):
9191

9292
def _fullTranslate(self, text, fastTranslation, language):
9393
if 0 == len(text):
94-
yield "", False
94+
yield None
9595
return
9696

9797
translationProcess = self._assistant.translate(

main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ def fastTranslated(self, text):
171171

172172
def fullTranslated(self, translationResult):
173173
self._lastAIResult = translationResult
174-
self._refineBtn.config(state=tk.DISABLED if translationResult.pending else tk.NORMAL)
174+
translation = '' if translationResult is None else translationResult.translation
175+
pending = False if translationResult is None else translationResult.pending
176+
177+
self._refineBtn.config(state=tk.DISABLED if pending else tk.NORMAL)
175178

176179
self._fullOutputText.delete("1.0", tk.END)
177-
self._fullOutputText.insert(tk.END, translationResult.translation)
180+
self._fullOutputText.insert(tk.END, translation)
178181

179-
if translationResult.pending:
182+
if pending:
180183
notification = self._localization(
181184
"Translation is not accurate and will be updated soon."
182185
).get()

0 commit comments

Comments
 (0)