From aabfa535bf1cb39a8b533d8e9d5be8a18d029c8e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 4 Sep 2023 12:26:27 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[update]=20auth=20key=E3=81=8C=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=80=81=E5=84=AA=E5=85=88=E7=9A=84=E3=81=ABDeepL(aut?= =?UTF-8?q?h)=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ※view.pyにprintToTextbox_AuthenticationSuccessが実装される前提で実装 --- main.py | 12 +++++------- model.py | 8 ++++++-- models/translation/translation_languages.py | 3 +-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 1ed44b42..93cb2a71 100644 --- a/main.py +++ b/main.py @@ -237,13 +237,11 @@ def callbackSetUiLanguage(value): # Translation Tab def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) - # config.AUTH_KEYS["DeepL(auth)"] = str(value) - # if len(value) > 0: - # if model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True: - # print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO") - # print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO") - # else: - # pass + if len(value) > 0 and model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True: + config.CHOICE_TRANSLATOR = "DeepL(auth)" + view.printToTextbox_AuthenticationSuccess() + else: + view.printToTextbox_AuthenticationError() # Transcription Tab (Mic) def callbackSetMicHost(value): diff --git a/model.py b/model.py index 48735c3d..20524129 100644 --- a/model.py +++ b/model.py @@ -78,7 +78,7 @@ class Model: if result: auth_keys = config.AUTH_KEYS auth_keys[choice_translator] = auth_key - fnc(auth_key) + fnc(auth_keys) return result def startLogger(self): @@ -119,7 +119,11 @@ class Model: target_languages = translation_lang.get(engine, {}).get("target", {}) if source_lang in source_languages and target_lang in target_languages: compatible_engines.append(engine) - return compatible_engines[0] + engine_name = compatible_engines[0] + + if engine_name == "DeepL(web)" and config.AUTH_KEYS["DeepL(auth)"] != None: + engine_name = "DeepL(auth)" + return engine_name def getTranslatorStatus(self): return self.translator.translator_status[config.CHOICE_TRANSLATOR] diff --git a/models/translation/translation_languages.py b/models/translation/translation_languages.py index a18eb5a1..1b68bf81 100644 --- a/models/translation/translation_languages.py +++ b/models/translation/translation_languages.py @@ -1,5 +1,4 @@ -# translatorEngine = ["DeepL(web)", "DeepL(auth)", "Google(web)", "Bing(web)"] -translatorEngine = ["DeepL(web)", "Google(web)", "Bing(web)"] +translatorEngine = ["DeepL(web)", "DeepL(auth)", "Google(web)", "Bing(web)"] translation_lang = {} dict_deepl_web_languages = { "Japanese":"JA", From a6137149a0f58e461ca79424ed0673de60fa3c13 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 4 Sep 2023 12:33:00 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Add]=20view.py=E3=81=ABprintToTextbox=5FAu?= =?UTF-8?q?thenticationSuccess=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/view.py b/view.py index 778f159a..c7e29804 100644 --- a/view.py +++ b/view.py @@ -360,6 +360,8 @@ class View(): def printToTextbox_disableForeground(self): self._printToTextbox_Info("Stop foreground") + def printToTextbox_AuthenticationSuccess(self): + self._printToTextbox_Info("Auth key update completed") def printToTextbox_AuthenticationError(self): self._printToTextbox_Info("Auth Key or language setting is incorrect") From 26403461b4fb77b94eac0e39e8088a42390b1ae6 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 4 Sep 2023 12:40:34 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[bugfix]=20model.findTranslationEngine?= =?UTF-8?q?=E3=81=A7=E7=BF=BB=E8=A8=B3=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3?= =?UTF-8?q?=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 93cb2a71..a5e5351b 100644 --- a/main.py +++ b/main.py @@ -238,7 +238,7 @@ def callbackSetUiLanguage(value): def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) if len(value) > 0 and model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True: - config.CHOICE_TRANSLATOR = "DeepL(auth)" + config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) view.printToTextbox_AuthenticationSuccess() else: view.printToTextbox_AuthenticationError()