👍[Update] Main : 翻訳エンジンの手動設定に変更

翻訳エンジンの自動設定機能を削除
input/outputの翻訳エンジンを別に設定できるように機能を追加
Aurhkeyの認証をDeepLのみ削減
This commit is contained in:
misyaguziya
2023-12-30 23:38:09 +09:00
parent a82435dc29
commit 1777988294
4 changed files with 112 additions and 66 deletions

View File

@@ -209,6 +209,12 @@ def messageBoxFocusOut(e):
model.oscStopSendTyping()
# func select languages
def initSetTranslateEngine():
engine = config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES[config.SELECTED_TAB_NO]
config.CHOICE_INPUT_TRANSLATOR = engine
engine = config.SELECTED_TAB_TARGET_TRANSLATOR_ENGINES[config.SELECTED_TAB_NO]
config.CHOICE_OUTPUT_TRANSLATOR = engine
def initSetLanguageAndCountry():
select = config.SELECTED_TAB_YOUR_LANGUAGES[config.SELECTED_TAB_NO]
language, country = model.getLanguageAndCountry(select)
@@ -218,7 +224,18 @@ def initSetLanguageAndCountry():
language, country = model.getLanguageAndCountry(select)
config.TARGET_LANGUAGE = language
config.TARGET_COUNTRY = country
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
def setYourTranslateEngine(select):
engines = config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES
engines[config.SELECTED_TAB_NO] = select
config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES = engines
config.CHOICE_INPUT_TRANSLATOR = select
def setTargetTranslateEngine(select):
engines = config.SELECTED_TAB_TARGET_TRANSLATOR_ENGINES
engines[config.SELECTED_TAB_NO] = select
config.SELECTED_TAB_TARGET_TRANSLATOR_ENGINES = engines
config.CHOICE_OUTPUT_TRANSLATOR = select
def setYourLanguageAndCountry(select):
languages = config.SELECTED_TAB_YOUR_LANGUAGES
@@ -227,7 +244,6 @@ def setYourLanguageAndCountry(select):
language, country = model.getLanguageAndCountry(select)
config.SOURCE_LANGUAGE = language
config.SOURCE_COUNTRY = country
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
view.printToTextbox_selectedYourLanguages(select)
def setTargetLanguageAndCountry(select):
@@ -237,7 +253,6 @@ def setTargetLanguageAndCountry(select):
language, country = model.getLanguageAndCountry(select)
config.TARGET_LANGUAGE = language
config.TARGET_COUNTRY = country
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
view.printToTextbox_selectedTargetLanguages(select)
def swapYourLanguageAndTargetLanguage():
@@ -252,17 +267,26 @@ def swapYourLanguageAndTargetLanguage():
def callbackSelectedLanguagePresetTab(selected_tab_no):
config.SELECTED_TAB_NO = selected_tab_no
view.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO)
engines = config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES
engine = engines[config.SELECTED_TAB_NO]
config.CHOICE_INPUT_TRANSLATOR = engine
engines = config.SELECTED_TAB_TARGET_TRANSLATOR_ENGINES
engine = engines[config.SELECTED_TAB_NO]
config.CHOICE_OUTPUT_TRANSLATOR = engine
languages = config.SELECTED_TAB_YOUR_LANGUAGES
select = languages[config.SELECTED_TAB_NO]
language, country = model.getLanguageAndCountry(select)
config.SOURCE_LANGUAGE = language
config.SOURCE_COUNTRY = country
languages = config.SELECTED_TAB_TARGET_LANGUAGES
select = languages[config.SELECTED_TAB_NO]
language, country = model.getLanguageAndCountry(select)
config.TARGET_LANGUAGE = language
config.TARGET_COUNTRY = country
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
view.printToTextbox_changedLanguagePresetTab(config.SELECTED_TAB_NO)
# command func
@@ -392,7 +416,7 @@ def callbackSetUiLanguage(value):
def callbackSetDeeplAuthkey(value):
print("callbackSetDeeplAuthkey", str(value))
if len(value) == 39:
result = model.authenticationTranslator(choice_translator="DeepL_API", auth_key=value)
result = model.authenticationTranslatorDeepLAuthKey(auth_key=value)
if result is True:
key = value
view.printToTextbox_AuthenticationSuccess()
@@ -402,12 +426,10 @@ def callbackSetDeeplAuthkey(value):
auth_keys = config.AUTH_KEYS
auth_keys["DeepL_API"] = key
config.AUTH_KEYS = auth_keys
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
elif len(value) == 0:
auth_keys = config.AUTH_KEYS
auth_keys["DeepL_API"] = None
config.AUTH_KEYS = auth_keys
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
# Transcription Tab (Mic)
def callbackSetMicHost(value):
@@ -703,15 +725,17 @@ def createMainWindow():
# init config
initSetConfigByExeArguments()
initSetTranslateEngine()
initSetLanguageAndCountry()
if model.authenticationTranslator(config.CHOICE_TRANSLATOR, config.AUTH_KEYS[config.CHOICE_TRANSLATOR]) is False:
# error update Auth key
auth_keys = config.AUTH_KEYS
auth_keys[config.CHOICE_TRANSLATOR] = None
config.AUTH_KEYS = auth_keys
view.printToTextbox_AuthenticationError()
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
# if (config.SELECTED_TAB_YOUR_TRANSLATOR_ENGINES[config.SELECTED_TAB_NO] == "DeepL_API" or
# config.SELECTED_TAB_TARGET_TRANSLATOR_ENGINES[config.SELECTED_TAB_NO] == "DeepL_API"):
# if model.authenticationTranslator("DeepL_API", config.AUTH_KEYS["DeepL_API"]) is False:
# # error update Auth key
# auth_keys = config.AUTH_KEYS
# auth_keys["DeepL_API"] = None
# config.AUTH_KEYS = auth_keys
# view.printToTextbox_AuthenticationError()
# set word filter
model.addKeywords()