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: c58d70fc4eb5960e8907c00a82bc662f95933615
This commit is contained in:
Physton
2023-06-02 19:08:35 +08:00
parent a698d39468
commit 4c47343e9f

View File

@@ -104,6 +104,8 @@ def translate(text, from_lang, to_lang, api, api_config = {}):
if item == None:
translate_indexes.append(index)
translate_texts.append(text[index])
if len(translate_texts) < 1:
return _translate_result(True, '', texts)
result = translator.translate_batch(translate_texts)
for index in range(len(result)):
item = result[index]