From e36e6fd1b15efd3c471d45a637d8fbe70ceab2ec Mon Sep 17 00:00:00 2001 From: GreenWizard Date: Fri, 29 Sep 2023 20:52:06 +0200 Subject: [PATCH] fix empty translation --- core/worker.py | 2 +- main.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/worker.py b/core/worker.py index c34a4f4..b949dfe 100644 --- a/core/worker.py +++ b/core/worker.py @@ -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( diff --git a/main.py b/main.py index 7596a63..003b228 100644 --- a/main.py +++ b/main.py @@ -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()