Some changes

This commit is contained in:
dazedanon 2025-06-17 12:11:10 -05:00
parent 6ce8c13936
commit 92c007cd25
5 changed files with 44 additions and 74 deletions

0
dazedwrap.py Normal file
View file

View file

@ -42,6 +42,7 @@ FIXTEXTWRAP = True # Overwrites textwrap
IGNORETLTEXT = False # Ignores all translated text. IGNORETLTEXT = False # Ignores all translated text.
MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong) MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong)
FILENAME = None FILENAME = None
TIMETOTAL = 0 # Total Time Taken for all translations
# tqdm Globals # tqdm Globals
BAR_FORMAT = "{l_bar}{bar:10}{r_bar}{bar:-10b}" BAR_FORMAT = "{l_bar}{bar:10}{r_bar}{bar:-10b}"
@ -121,11 +122,15 @@ def getResultString(translatedData, translationTime, filename):
+ "]" "[Cost: ${:,.4f}".format(((translatedData[1][0] / 1000000) * INPUTAPICOST) + ((translatedData[1][1] / 1000000) * OUTPUTAPICOST)) + "]" "[Cost: ${:,.4f}".format(((translatedData[1][0] / 1000000) * INPUTAPICOST) + ((translatedData[1][1] / 1000000) * OUTPUTAPICOST))
+ "]" + "]"
) )
timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]" if filename != "TOTAL":
timeString = Fore.BLUE + "[" + str(round(translationTime, 1)) + "s]"
TIMETOTAL += round(translationTime, 1)
else:
timeString = Fore.BLUE + "[" + str(round(TIMETOTAL, 1)) + "s]"
if translatedData[2] == None: if translatedData[2] == None:
# Success # Success
return filename + ": " + totalTokenstring + timeString + Fore.GREEN + " \u2713 " + Fore.RESET return filename + ": " + totalTokenstring + timeString + Fore.GREEN + " \u2713 " + Fore.RESET
else: else:
# Fail # Fail
@ -187,8 +192,8 @@ def translateRegex(data, translatedList):
while i < len(data): while i < len(data):
voice = False voice = False
lineRegexText = r"(^[^*_]+$)" lineRegexText = r"◆B.+?◆(.+)"
lineRegexSpeaker = r"(主人公)\n" lineRegexSpeaker = r"◆A.+?◆(.+)"
choiceRegex = r"\$menu_item.+?,(.*?)," choiceRegex = r"\$menu_item.+?,(.*?),"
titleRegex = r"title\s'(.*)'$" titleRegex = r"title\s'(.*)'$"
speaker = "" speaker = ""
@ -223,7 +228,7 @@ def translateRegex(data, translatedList):
tokens[1] += response[1][1] tokens[1] += response[1][1]
if translatedList: if translatedList:
data[i] = data[i].replace(match.group(1), speaker) data[i] = data[i].replace(match.group(1), speaker)
i += 1 i += 3
else: else:
speaker = None speaker = None
elif data[i] == "Protagonist\n": elif data[i] == "Protagonist\n":
@ -240,24 +245,13 @@ def translateRegex(data, translatedList):
# Save Original String # Save Original String
originalString = jaString originalString = jaString
# Check if next lines are strings
jaStringLines = [jaString]
match = re.search(lineRegexText, data[i + 1])
while match and match.group(0) != '\n':
jaStringLines.append(match.group(1))
del data[i + 1]
match = re.search(lineRegexText, data[i + 1])
# Combine
jaString = "".join(jaStringLines)
# Pass 1 # Pass 1
if not translatedList: if not translatedList:
# Strip Spaces # Strip Spaces
jaString = jaString.strip() jaString = jaString.strip()
# Remove Textwrap # Remove Textwrap
jaString = jaString.replace('\n', ' ') jaString = jaString.replace('\\n', ' ')
if jaString: if jaString:
if speaker: if speaker:
@ -283,18 +277,18 @@ def translateRegex(data, translatedList):
# Escape Quotes # Escape Quotes
translatedText = re.sub(r'(?<!\\)"', r"", translatedText) translatedText = re.sub(r'(?<!\\)"', r"", translatedText)
# Remove Repeating Characters # Remove characters that may break scripts
pattern = re.compile(r"(.)\s*\1(?:\s*\1){" + str(20 - 1) + r",}") translatedText = translatedText.replace("<", "(")
translatedText = pattern.sub(lambda match: match.group(0).replace(" ", "")[:20], translatedText) translatedText = translatedText.replace(">", ")")
# Textwrap # Textwrap
translatedText = textwrap.fill(translatedText, width=WIDTH) translatedText = textwrap.fill(translatedText, width=WIDTH).replace("\n", "\\n")
# Set Data # Set Data
if "" in originalString and "" not in translatedText: if "" in data[i-1] and "" not in translatedText:
data[i] = f"{translatedText}\n" data[i] = data[i].replace(originalString, f"{translatedText}")
else: else:
data[i] = f"{translatedText}\n" data[i] = data[i].replace(originalString, f"{translatedText}")
# Choices # Choices
match = re.search(choiceRegex, data[i]) match = re.search(choiceRegex, data[i])

View file

@ -92,10 +92,10 @@ CODE101 = False # Turn this one when names exist in 101
CODE408 = False # Warning, translates comments and can inflate costs. CODE408 = False # Warning, translates comments and can inflate costs.
# Variables # Variables
CODE122 = False CODE122 = True
# Other # Other
CODE355655 = True CODE355655 = False
CODE357 = False CODE357 = False
CODE657 = False CODE657 = False
CODE356 = False CODE356 = False

View file

@ -85,7 +85,7 @@ CODE101 = False
CODE102 = False CODE102 = False
# Set String (Fragile but necessary) # Set String (Fragile but necessary)
CODE122 = False CODE122 = True
CODE150 = False CODE150 = False
# Other # Other
@ -99,12 +99,12 @@ OPTIONSFLAG = False
NPCFLAG = False NPCFLAG = False
DBNAMEFLAG = False DBNAMEFLAG = False
DBVALUEFLAG = False DBVALUEFLAG = False
ITEMFLAG = False ITEMFLAG = True
STATEFLAG = False STATEFLAG = False
ENEMYFLAG = False ENEMYFLAG = False
ARMORFLAG = False ARMORFLAG = False
WEAPONFLAG = False WEAPONFLAG = False
SKILLFLAG = True SKILLFLAG = False
def handleWOLF(filename, estimate): def handleWOLF(filename, estimate):
@ -929,7 +929,7 @@ def searchDB(events, pbar, jobList, filename):
try: try:
for table in tableList: for table in tableList:
# Grab NPCs # Grab NPCs
if table["name"] == "マップ選択画面" and NPCFLAG == True: if table["name"] == "主人公ステータス" and NPCFLAG == True:
with open("translations.txt", "a", encoding="utf-8") as file: with open("translations.txt", "a", encoding="utf-8") as file:
if setData: if setData:
file.write(f"\n#Actors\n") file.write(f"\n#Actors\n")
@ -939,7 +939,7 @@ def searchDB(events, pbar, jobList, filename):
# Parse # Parse
for j in range(len(dataList)): for j in range(len(dataList)):
# Name # Name
if dataList[j].get("name") == "マップ": if dataList[j].get("name") == "キャラ":
# Pass 1 (Grab Data) # Pass 1 (Grab Data)
if setData == False: if setData == False:
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
@ -956,7 +956,7 @@ def searchDB(events, pbar, jobList, filename):
npcList[0].pop(0) npcList[0].pop(0)
# Description # Description
if dataList[j].get("name") == "NULL": if dataList[j].get("name") == "肩書き":
# Pass 1 (Grab Data) # Pass 1 (Grab Data)
if setData == False: if setData == False:
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
@ -1290,8 +1290,8 @@ def searchDB(events, pbar, jobList, filename):
dataList = item["data"] dataList = item["data"]
# Parse # Parse
font = 20
for j in range(len(dataList)): for j in range(len(dataList)):
font = 24
# Name # Name
if dataList[j].get("name") == "アイテム名": if dataList[j].get("name") == "アイテム名":
jaString = dataList[j].get("value") jaString = dataList[j].get("value")
@ -1311,7 +1311,7 @@ def searchDB(events, pbar, jobList, filename):
itemList[0].pop(0) itemList[0].pop(0)
# Description # Description
if dataList[j].get("name") == "説明文[2行まで可]": if dataList[j].get("name") == "NULL":
# Pass 1 (Grab Data) # Pass 1 (Grab Data)
if setData == False: if setData == False:
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
@ -1328,7 +1328,7 @@ def searchDB(events, pbar, jobList, filename):
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
# Textwrap # Textwrap
translatedText = itemList[1][0] translatedText = itemList[1][0]
translatedText = textwrap.fill(translatedText, LISTWIDTH) # translatedText = textwrap.fill(translatedText, LISTWIDTH)
# Font # Font
if font: if font:
@ -1339,7 +1339,7 @@ def searchDB(events, pbar, jobList, filename):
itemList[1].pop(0) itemList[1].pop(0)
# Log # Log
if dataList[j].get("name") == "使用時文章": if dataList[j].get("name") == "使用時文章[戦](人名~":
# Pass 1 (Grab Data) # Pass 1 (Grab Data)
if setData == False: if setData == False:
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
@ -1454,14 +1454,14 @@ def searchDB(events, pbar, jobList, filename):
armorList[1].pop(0) armorList[1].pop(0)
# Grab Enemies # Grab Enemies
if table["name"] == "" and ENEMYFLAG == True: if table["name"] == "キャラ個体データ" and ENEMYFLAG == True:
for enemy in table["data"]: for enemy in table["data"]:
dataList = enemy["data"] dataList = enemy["data"]
# Parse # Parse
for j in range(len(dataList)): for j in range(len(dataList)):
# Name # Name
if dataList[j].get("name") == "": if dataList[j].get("name") == "敵キャラ":
# Pass 1 (Grab Data) # Pass 1 (Grab Data)
if setData == False: if setData == False:
if dataList[j].get("value") != "": if dataList[j].get("value") != "":
@ -1492,7 +1492,10 @@ def searchDB(events, pbar, jobList, filename):
# Textwrap # Textwrap
translatedText = enemyList[1][0] translatedText = enemyList[1][0]
translatedText = textwrap.fill(translatedText, LISTWIDTH) translatedText = textwrap.fill(translatedText, LISTWIDTH)
translatedText = font + translatedText
# Font
if font:
translatedText = f"\\f[{font}]{translatedText}"
# Set Data # Set Data
dataList[j].update({"value": translatedText}) dataList[j].update({"value": translatedText})

View file

@ -1,19 +1,12 @@
Here are some vocabulary and terms so that you know the proper spelling and translation. Here are some vocabulary and terms so that you know the proper spelling and translation.
``` ```
# Game Characters # Game Characters
ソフィー (Sophie) - Female Taro - Male
カタリナ (Katarina) - Female 羽田 千紗 (Haneda Chisa) - Female
師匠ドロシア (Master Dorothea) - Female 川村 芳乃 (Kawamura Yoshino) - Female
ギルド女性受付 (Guild Receptionist) - Female 御小柴 朱梨 (Mikoshiba Shuri) - Female
娼館受付 (Brothel Receptionist) - Female 早乙女 恭香 (Saotome Kyouka) - Female
ドミ (Domi) - Unknown 夢園 蓮美 (Yumezono Hasumi) - Female
姫ヶ崎エミリー (Emily Himegasaki) - Female
冒険者ジャック (Adventurer Jack) - Male
カボチャ女 (Pumpkin Woman) - Female
カボチャ男 (Pumpkin Man) - Male
エマえがお (Emma) - Female
ジーナ (Gina) - Female
諸葛霊孔明 (Zhuge Ling Kongming) - Male
# Lewd Terms # Lewd Terms
マンコ (pussy) マンコ (pussy)
@ -157,25 +150,5 @@ w ((lol))
』 (』) 』 (』)
# Game Specific # Game Specific
獣の魔女 (Beast Witch)
ルーンフェリア (Runefellia)
ミストウッド雪森 (Mistwood Snow Forest)
ソフィーリアの家 (Sophiria's House)
聖都ノーブルヘイツ (Holy City Noble Heights)
ゴルマンの宿 (Golman's Inn)
華都エルムリッジ (Splendid City Elmridge)
炭鉱都グリムストーン (Mining City Grimstone)
エルムリッジ街道 (Elmridge Highway)
炭鉱都ギルド (Mining City Guild)
王都グランヘイツ (Royal Capital Granheights)
ギルド本部 (Guild Headquarters)
封鎖坑道 (Sealed Tunnel)
錆びれた廃城 (Rusty Abandoned Castle/Ruined Castle)
離島洞穴 (Isolated Island Cave)
海都シーグレイ (Sea Capital Seagray)
精霊都 ダストバレー (Spirit Capital Dust Valley)
シルバーブルック (Silverbrook)
領主邸 (Lord's Mansion)
銀の塔 (Silver Tower)
聖女遺跡 (Saintess Ruins)
``` ```