From 6546d56abe883d8c364417e487b495f5132c8b47 Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Thu, 19 Dec 2024 13:19:23 -0600 Subject: [PATCH] Formatting --- modules/csv.py | 2 +- modules/json.py | 2 +- modules/nscript.py | 5 +---- modules/regex.py | 35 +++++++++++++++++++++++++++++++++-- modules/renpy.py | 2 +- modules/rpgmakerace.py | 2 +- modules/rpgmakermvmz.py | 2 +- modules/rpgmakerplugin.py | 2 +- modules/text.py | 2 +- modules/tyrano.py | 2 +- modules/wolf.py | 2 +- modules/wolf2.py | 2 +- 12 files changed, 44 insertions(+), 16 deletions(-) diff --git a/modules/csv.py b/modules/csv.py index b4de1cc..a9a64c2 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -622,4 +622,4 @@ def translateGPT(text, history, fullPromptFlag): tList[index] = translatedText.replace("Placeholder Text", "") finalList = combineList(tList, text) - return [finalList, totalTokens] \ No newline at end of file + return [finalList, totalTokens] diff --git a/modules/json.py b/modules/json.py index 30fbd58..e4859b8 100644 --- a/modules/json.py +++ b/modules/json.py @@ -563,4 +563,4 @@ def translateGPT(text, history, fullPromptFlag): tList[index] = translatedText.replace("Placeholder Text", "") finalList = combineList(tList, text) - return [finalList, totalTokens] \ No newline at end of file + return [finalList, totalTokens] diff --git a/modules/nscript.py b/modules/nscript.py index 1b00918..ee3754e 100644 --- a/modules/nscript.py +++ b/modules/nscript.py @@ -622,7 +622,4 @@ def translateGPT(text, history, fullPromptFlag): tList[index] = translatedText.replace("Placeholder Text", "") finalList = combineList(tList, text) - if format == "json": - return [finalList, totalTokens] - else: - return [finalList[0], totalTokens] + return [finalList, totalTokens] diff --git a/modules/regex.py b/modules/regex.py index 4dee434..1ca3bd0 100644 --- a/modules/regex.py +++ b/modules/regex.py @@ -189,6 +189,24 @@ def translateRegex(data, translatedList): lineRegexText = r"t\s'(.*)'$" lineRegexSpeaker = r"n\s'(.*)'$" choiceRegex = r"choice:\d+\s'(.*)'" + titleRegex = r"title\s'(.*)'$" + + # Title + match = re.search(titleRegex, data[i]) + if match: + response = translateGPT( + [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 + if translatedList: + title = re.sub(r"(?