diff --git a/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py b/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py index 1cbb5f5a..735aa1ba 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py +++ b/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py @@ -136,8 +136,7 @@ class Process: res = reg.sub(self.vnrshareddict[context[key]]["text"], res) for key, value in self.sorted_vnrshareddict_post: if key in res: - res = res.replace(key, value["text"]) - res = res.replace(key.lower(), value["text"]) + res = re.sub(key, value["text"], res, flags=re.IGNORECASE) return res @staticmethod diff --git a/LunaTranslator/LunaTranslator/transoptimi/noundict.py b/LunaTranslator/LunaTranslator/transoptimi/noundict.py index 0260fb67..c799100c 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/noundict.py +++ b/LunaTranslator/LunaTranslator/transoptimi/noundict.py @@ -1,5 +1,5 @@ from myutils.config import savehook_new_data, globalconfig -import gobject +import gobject, re from qtsymbols import * from myutils.utils import postusewhich from myutils.config import get_launchpath @@ -89,6 +89,5 @@ class Process: def process_after(self, res: str, context): mp1 = context["zhanweifu"] for key in mp1: - res = res.replace(key, mp1[key]) - res = res.replace(key.lower(), mp1[key]) + res = re.sub(key, mp1[key], res, flags=re.IGNORECASE) return res