MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / translate_worker

Function translate_worker

utils/google_translate.py:173–179  ·  view source on GitHub ↗
(chinese_texts, translations, lang)

Source from the content-addressed store, hash-verified

171
172# 锁
173def translate_worker(chinese_texts, translations, lang):
174 for idx, chinese_text in chinese_texts:
175 translated_text = translate_text(chinese_text, lang)
176 if translated_text:
177 # 使用锁确保线程安全地修改 translations
178 with translation_lock:
179 translations[(idx, chinese_text)] = translated_text
180
181
182# 翻译并保存结果,覆盖原文件

Callers

nothing calls this directly

Calls 1

translate_textFunction · 0.85

Tested by

no test coverage detected