From fa32d0ff87de3b6955d86d807923f57cea323aae Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 31 Dec 2023 00:36:50 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D[Update]=20Model=20:=20=E6=96=87?= =?UTF-8?q?=E5=AD=97=E8=B5=B7=E3=81=93=E3=81=97=E3=81=A8=E7=BF=BB=E8=A8=B3?= =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E3=81=AE=E7=B5=84=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=AE=E6=9C=89=E5=8A=B9=E6=80=A7=E8=BE=9E=E6=9B=B8?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getDictTranslationEngineValidity --- model.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/model.py b/model.py index 30e6a852..f5d4c0d7 100644 --- a/model.py +++ b/model.py @@ -126,15 +126,32 @@ class Model: # if source_lang in source_languages and target_lang in target_languages: # compatible_engines.append(engine) # engine_name = compatible_engines[0] - # if engine_name == "DeepL" and config.AUTH_KEYS["DeepL_API"] is not None: # if self.authenticationTranslator(engine_name, config.AUTH_KEYS["DeepL_API"]) is True: # engine_name = "DeepL_API" # elif engine_name == "DeepL_API" and config.AUTH_KEYS["DeepL_API"] is None: # engine_name = "DeepL" - # return engine_name + def getDictTranslationEngineValidity(self): + ts_keys = transcription_lang.keys() + tl_keys = translation_lang.keys() + te_dict = {} + for ts_key in ts_keys: + te_dict[ts_key] = {} + for tl_key in tl_keys: + te_dict[ts_key][tl_key] = False + if ts_key in translation_lang[tl_key]["source"]: + te_dict[ts_key][tl_key] = True + + keys_to_remove = [] + for language, translation_dict in te_dict.items(): + if all(value is False for value in translation_dict.values()): + keys_to_remove.append(language) + for key in keys_to_remove: + del te_dict[key] + return te_dict + def getInputTranslate(self, message): translator_name=config.CHOICE_INPUT_TRANSLATOR source_language=config.SOURCE_LANGUAGE