From 0019d6e7d81b8b83ffc0aa0fc19d9752594a3af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Sun, 29 Dec 2024 00:48:54 +0800 Subject: [PATCH] . --- py/LunaTranslator/translator/rengong.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/py/LunaTranslator/translator/rengong.py b/py/LunaTranslator/translator/rengong.py index 99a86a96..d9ece931 100644 --- a/py/LunaTranslator/translator/rengong.py +++ b/py/LunaTranslator/translator/rengong.py @@ -27,7 +27,10 @@ class TS(basetrans): return with open(pp, "r", encoding="utf8") as f: try: - self.json.update(json.load(f)) + for k, v in json.load(f).items(): + if k not in self.json: + self.json[k] = [] + self.json[k].append(v) except: pass @@ -47,7 +50,7 @@ class TS(basetrans): self.unsafegetcurrentgameconfig(), tuple(self.config["jsonfile"]) ) - def analyze_result(self, obj): + def analyze_result__(self, obj): if type(obj) == str: return obj if type(obj) != dict: @@ -63,6 +66,14 @@ class TS(basetrans): return None + def analyze_result(self, obj): + _x = [] + for _ in obj: + __ = self.analyze_result__(_) + if __: + _x.append(__) + return _x + def delayloadlines(self): if self.lines is not None: return @@ -110,8 +121,8 @@ class TS(basetrans): line = self.tryfindtranslate(line, self.json, self.lines) if not line: return None - collect.append(line) - return "\n".join(collect) + collect.append("\n".join(line)) + return collect def translate(self, content): self.checkfilechanged( @@ -122,4 +133,4 @@ class TS(basetrans): res = self.tryfindtranslate_single(content) if not res: raise Exception("can't find: " + content) - return res + return "\n".join(res)