Skip to content

Commit

Permalink
fix empty translation
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenWizard2015 committed Sep 29, 2023
1 parent 2a7ba3d commit e36e6fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _fastTranslate(self, text, languageCode):

def _fullTranslate(self, text, fastTranslation, language):
if 0 == len(text):
yield "", False
yield None
return

translationProcess = self._assistant.translate(
Expand Down
9 changes: 6 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ def fastTranslated(self, text):

def fullTranslated(self, translationResult):
self._lastAIResult = translationResult
self._refineBtn.config(state=tk.DISABLED if translationResult.pending else tk.NORMAL)
translation = '' if translationResult is None else translationResult.translation
pending = False if translationResult is None else translationResult.pending

self._refineBtn.config(state=tk.DISABLED if pending else tk.NORMAL)

self._fullOutputText.delete("1.0", tk.END)
self._fullOutputText.insert(tk.END, translationResult.translation)
self._fullOutputText.insert(tk.END, translation)

if translationResult.pending:
if pending:
notification = self._localization(
"Translation is not accurate and will be updated soon."
).get()
Expand Down

0 comments on commit e36e6fd

Please sign in to comment.