This commit is contained in:
恍兮惚兮 2024-06-21 18:03:52 +08:00
parent 2f8ea2003f
commit cc84f37544
2 changed files with 23 additions and 20 deletions

View File

@ -332,20 +332,19 @@ class MAINUI:
returnandembedcallback = lambda x: embedcallback(x) if embedcallback else "" returnandembedcallback = lambda x: embedcallback(x) if embedcallback else ""
if type(res) == str: if res.startswith("<msg_translator>"):
if res.startswith("<msg_translator>"): if currentsignature == self.currentsignature:
if currentsignature == self.currentsignature: self.translation_ui.displaystatus.emit(
self.translation_ui.displaystatus.emit( globalconfig["fanyi"][classname]["name"]
globalconfig["fanyi"][classname]["name"] + " "
+ " " + res[len("<msg_translator>") :],
+ res[len("<msg_translator>") :], "red",
"red", onlytrans,
onlytrans, False,
False, )
) if len(self.usefultranslators) == 0:
if len(self.usefultranslators) == 0: returnandembedcallback("")
returnandembedcallback("") return
return
res = self.solveaftertrans(res, optimization_params) res = self.solveaftertrans(res, optimization_params)
if len(res) == 0: if len(res) == 0:

View File

@ -280,16 +280,20 @@ class basetrans(commonbase):
if succ: if succ:
__callback("", 2) __callback("", 2)
def __callback(self, collectiterres, callback, embedcallback, _, is_iter_res): def __callback(self, collectiterres, callback, embedcallback, ares, is_iter_res):
if self.needzhconv: if self.needzhconv:
_ = zhconv.convert(_, "zh-tw") ares = zhconv.convert(ares, "zh-tw")
if _ == "\0": # 清除前面的输出 if ares == "\0": # 清除前面的输出
collectiterres.clear() collectiterres.clear()
pass pass
else: else:
collectiterres.append(_) collectiterres.append(ares)
if all([_ is not None for _ in collectiterres]): __ = ""
callback("".join(collectiterres), embedcallback, is_iter_res) for ares in collectiterres:
if ares is None:
continue
__ += ares
callback(__, embedcallback, is_iter_res)
def reinitandtrans(self, contentraw, contentsolved, is_auto_run): def reinitandtrans(self, contentraw, contentsolved, is_auto_run):
if self.needreinit or self.initok == False: if self.needreinit or self.initok == False: