mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-05-01 03:31:41 +00:00
Optimize the translation code and significantly improve the batch translation speed
Optimize the translation code and significantly improve the batch translation speed Former-commit-id: 92bf6d724e4b87e3a9a8d2777810118c011256f2
This commit is contained in:
@@ -7,7 +7,7 @@ class DeeplTranslator(BaseTranslator):
|
||||
|
||||
def translate(self, text):
|
||||
if not text:
|
||||
if isinstance(result['translations'], list):
|
||||
if isinstance(text, list):
|
||||
return []
|
||||
else:
|
||||
return ''
|
||||
@@ -32,7 +32,7 @@ class DeeplTranslator(BaseTranslator):
|
||||
raise Exception(result['message'])
|
||||
if 'translations' not in result:
|
||||
raise Exception("No response from DeepL")
|
||||
if isinstance(result['translations'], list):
|
||||
if isinstance(text, list):
|
||||
results = []
|
||||
for item in result['translations']:
|
||||
results.append(item['text'])
|
||||
|
||||
@@ -8,7 +8,7 @@ class MicrosoftTranslator(BaseTranslator):
|
||||
|
||||
def translate(self, text):
|
||||
if not text:
|
||||
if isinstance(result['translations'], list):
|
||||
if isinstance(text, list):
|
||||
return []
|
||||
else:
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user