Merge branch 'bugfix_authcheck' into UI_2.0
This commit is contained in:
11
main.py
11
main.py
@@ -162,6 +162,7 @@ def setYourLanguageAndCountry(select):
|
|||||||
config.SOURCE_LANGUAGE = language
|
config.SOURCE_LANGUAGE = language
|
||||||
config.SOURCE_COUNTRY = country
|
config.SOURCE_COUNTRY = country
|
||||||
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
|
|
||||||
def setTargetLanguageAndCountry(select):
|
def setTargetLanguageAndCountry(select):
|
||||||
languages = config.SELECTED_TAB_TARGET_LANGUAGES
|
languages = config.SELECTED_TAB_TARGET_LANGUAGES
|
||||||
@@ -171,6 +172,7 @@ def setTargetLanguageAndCountry(select):
|
|||||||
config.TARGET_LANGUAGE = language
|
config.TARGET_LANGUAGE = language
|
||||||
config.TARGET_COUNTRY = country
|
config.TARGET_COUNTRY = country
|
||||||
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
|
|
||||||
def callbackSelectedLanguagePresetTab(selected_tab_no):
|
def callbackSelectedLanguagePresetTab(selected_tab_no):
|
||||||
config.SELECTED_TAB_NO = selected_tab_no
|
config.SELECTED_TAB_NO = selected_tab_no
|
||||||
@@ -186,6 +188,7 @@ def callbackSelectedLanguagePresetTab(selected_tab_no):
|
|||||||
config.TARGET_LANGUAGE = language
|
config.TARGET_LANGUAGE = language
|
||||||
config.TARGET_COUNTRY = country
|
config.TARGET_COUNTRY = country
|
||||||
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
|
|
||||||
def callbackSetAuthKeys(keys):
|
def callbackSetAuthKeys(keys):
|
||||||
config.AUTH_KEYS = keys
|
config.AUTH_KEYS = keys
|
||||||
@@ -299,7 +302,13 @@ def callbackSetDeeplAuthkey(value):
|
|||||||
print("callbackSetDeeplAuthkey", str(value))
|
print("callbackSetDeeplAuthkey", str(value))
|
||||||
if len(value) > 0 and model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True:
|
if len(value) > 0 and model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True:
|
||||||
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
view.printToTextbox_AuthenticationSuccess()
|
view.printToTextbox_AuthenticationSuccess()
|
||||||
|
elif len(value) == 0:
|
||||||
|
auth_keys = config.AUTH_KEYS
|
||||||
|
auth_keys["DeepL(auth)"] = None
|
||||||
|
config.AUTH_KEYS = auth_keys
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
else:
|
else:
|
||||||
view.printToTextbox_AuthenticationError()
|
view.printToTextbox_AuthenticationError()
|
||||||
|
|
||||||
@@ -521,6 +530,8 @@ view.createGUI()
|
|||||||
if model.authenticationTranslator(callbackSetAuthKeys) is False:
|
if model.authenticationTranslator(callbackSetAuthKeys) is False:
|
||||||
# error update Auth key
|
# error update Auth key
|
||||||
view.printToTextbox_AuthenticationError()
|
view.printToTextbox_AuthenticationError()
|
||||||
|
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
|
||||||
|
model.authenticationTranslator(callbackSetAuthKeys)
|
||||||
|
|
||||||
# set word filter
|
# set word filter
|
||||||
model.addKeywords()
|
model.addKeywords()
|
||||||
|
|||||||
@@ -13,23 +13,23 @@ class Translator():
|
|||||||
|
|
||||||
def authentication(self, translator_name, authkey=None):
|
def authentication(self, translator_name, authkey=None):
|
||||||
result = False
|
result = False
|
||||||
try:
|
if translator_name == "DeepL(web)":
|
||||||
if translator_name == "DeepL(web)":
|
self.translator_status[translator_name] = True
|
||||||
self.translator_status["DeepL(web)"] = True
|
result = True
|
||||||
result = True
|
elif translator_name == "DeepL(auth)":
|
||||||
elif translator_name == "DeepL(auth)":
|
try:
|
||||||
self.deepl_client = deepl_Translator(authkey)
|
self.deepl_client = deepl_Translator(authkey)
|
||||||
self.deepl_client.translate_text(" ", target_lang="EN-US")
|
self.deepl_client.translate_text(" ", target_lang="EN-US")
|
||||||
self.translator_status["DeepL(auth)"] = True
|
self.translator_status[translator_name] = True
|
||||||
result = True
|
result = True
|
||||||
elif translator_name == "Google(web)":
|
except:
|
||||||
self.translator_status["Google(web)"] = True
|
self.translator_status[translator_name] = False
|
||||||
result = True
|
elif translator_name == "Google(web)":
|
||||||
elif translator_name == "Bing(web)":
|
self.translator_status[translator_name] = True
|
||||||
self.translator_status["Bing(web)"] = True
|
result = True
|
||||||
result = True
|
elif translator_name == "Bing(web)":
|
||||||
except:
|
self.translator_status[translator_name] = True
|
||||||
pass
|
result = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def translate(self, translator_name, source_language, target_language, message):
|
def translate(self, translator_name, source_language, target_language, message):
|
||||||
|
|||||||
Reference in New Issue
Block a user