From bbbc28168112f49ca7c8b5acd7515d0f409282ed Mon Sep 17 00:00:00 2001 From: dazedanon Date: Sat, 13 Dec 2025 13:31:06 -0600 Subject: [PATCH] Changes --- modules/regex.py | 107 +++++++++++++++++++++++++++++++++++----- modules/rpgmakermvmz.py | 2 +- 2 files changed, 97 insertions(+), 12 deletions(-) diff --git a/modules/regex.py b/modules/regex.py index 105de20..6a978f1 100644 --- a/modules/regex.py +++ b/modules/regex.py @@ -205,25 +205,48 @@ def translateRegex(data, filename, translatedList): while i < len(data): voice = False lineRegexText = r'●(?:「| |()+(.+?)(?:[」)]|$)+' - lineRegexSpeaker = r"text\(\"(.+)\"\)" + lineRegexSpeaker = r"\\text\(\"(.+?)\"\)" choiceRegex = r"\$menu_item.+?,(.*?)," titleRegex = r"title\s'(.*)'$" + setgamedatatitleRegex = r'\\setgamedatatitle\("(.+?)"\)' + dlgRegex = r'\\dlg\("(.+?)"\)' + selRegex = r'\\sel\((.+)\)' speaker = "" + # Setgamedatatitle + match = re.search(setgamedatatitleRegex, data[i]) + if match: + # Pass 1 - Translate immediately (not batched) + if not translatedList: + response = translateAI( + match.group(1).replace('\\n', '\n'), + f"Reply with the {LANGUAGE} translation of the chapter title", + True, + ) + tokens[0] += response[1][0] + tokens[1] += response[1][1] + title = response[0] + + # Convert newlines back to escape sequences and escape quotes + title = title.replace('\n', '\\n').replace('"', '\\"') + data[i] = data[i].replace(match.group(1), title) + save_progress_lines(data, filename) + # Title match = re.search(titleRegex, data[i]) if match: - response = translateAI( - match.group(1), - f"Reply with the {LANGUAGE} translation of the chapter title", - True, - ) - tokens[0] += response[1][0] - tokens[1] += response[1][1] - title = response[0] - - # Set + # Pass 1 - Translate immediately (not batched) if not translatedList: + response = translateAI( + match.group(1), + f"Reply with the {LANGUAGE} translation of the chapter title", + True, + ) + tokens[0] += response[1][0] + tokens[1] += response[1][1] + title = response[0] + + # Set title = re.sub(r"(?