Skip to content

Commit

Permalink
optim sakura lb
Browse files Browse the repository at this point in the history
  • Loading branch information
xd2333 committed Jun 23, 2024
1 parent c898804 commit 8915483
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions GalTransl/Backend/SakuraTranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ async def translate(self, trans_list: CTransList, gptdict=""):
max_len = 0
for i, trans in enumerate(trans_list):
# 处理换行
tmp_text = trans.post_jp.replace("\r\n", "\\n").replace("\n", "\\n")
if self.eng_type in ["sakura-009", "sakura-010"]:
tmp_text = trans.post_jp.replace("\r\n", "↓↓").replace("\n", "↓↓")
else:
tmp_text = trans.post_jp.replace("\r\n", "\\n").replace("\n", "\\n")
# 有name
if trans.speaker != "":
tmp_text = f"{trans.speaker}{tmp_text}」"
Expand Down Expand Up @@ -209,9 +212,9 @@ async def translate(self, trans_list: CTransList, gptdict=""):
line = self.opencc.convert(line)
# 还原换行
if "\r\n" in trans_list[i].post_jp:
line = line.replace("\\n", "\r\n")
line = line.replace("↓↓", "\r\n").replace("\\n", "\r\n")
elif "\n" in trans_list[i].post_jp:
line = line.replace("\\n", "\n")
line = line.replace("↓↓", "\n").replace("\\n", "\n")

# fix trick
if line.startswith(":"):
Expand Down

0 comments on commit 8915483

Please sign in to comment.