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.
MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong)
FILENAME = None
TIMETOTAL = 0 # Total Time Taken for all translations
# tqdm Globals
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))
+ "]"
)
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:
# Success
return filename + ": " + totalTokenstring + timeString + Fore.GREEN + " \u2713 " + Fore.RESET
return filename + ": " + totalTokenstring + timeString + Fore.GREEN + " \u2713 " + Fore.RESET
else:
# Fail
@ -187,8 +192,8 @@ def translateRegex(data, translatedList):
while i < len(data):
voice = False
lineRegexText = r"(^[^*_]+$)"
lineRegexSpeaker = r"(主人公)\n"
lineRegexText = r"◆B.+?◆(.+)"
lineRegexSpeaker = r"◆A.+?◆(.+)"
choiceRegex = r"\$menu_item.+?,(.*?),"
titleRegex = r"title\s'(.*)'$"
speaker = ""
@ -223,7 +228,7 @@ def translateRegex(data, translatedList):
tokens[1] += response[1][1]
if translatedList:
data[i] = data[i].replace(match.group(1), speaker)
i += 1
i += 3
else:
speaker = None
elif data[i] == "Protagonist\n":
@ -240,24 +245,13 @@ def translateRegex(data, translatedList):
# Save Original String
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
if not translatedList:
# Strip Spaces
jaString = jaString.strip()
# Remove Textwrap
jaString = jaString.replace('\n', ' ')
jaString = jaString.replace('\\n', ' ')
if jaString:
if speaker:
@ -283,18 +277,18 @@ def translateRegex(data, translatedList):
# Escape Quotes
translatedText = re.sub(r'(?<!\\)"', r"", translatedText)
# Remove Repeating Characters
pattern = re.compile(r"(.)\s*\1(?:\s*\1){" + str(20 - 1) + r",}")
translatedText = pattern.sub(lambda match: match.group(0).replace(" ", "")[:20], translatedText)
# Remove characters that may break scripts
translatedText = translatedText.replace("<", "(")
translatedText = translatedText.replace(">", ")")
# Textwrap
translatedText = textwrap.fill(translatedText, width=WIDTH)
translatedText = textwrap.fill(translatedText, width=WIDTH).replace("\n", "\\n")
# Set Data
if "" in originalString and "" not in translatedText:
data[i] = f"{translatedText}\n"
if "" in data[i-1] and "" not in translatedText:
data[i] = data[i].replace(originalString, f"{translatedText}")
else:
data[i] = f"{translatedText}\n"
data[i] = data[i].replace(originalString, f"{translatedText}")
# Choices
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.
# Variables
CODE122 = False
CODE122 = True
# Other
CODE355655 = True
CODE355655 = False
CODE357 = False
CODE657 = False
CODE356 = False

View file

@ -85,7 +85,7 @@ CODE101 = False
CODE102 = False
# Set String (Fragile but necessary)
CODE122 = False
CODE122 = True
CODE150 = False
# Other
@ -99,12 +99,12 @@ OPTIONSFLAG = False
NPCFLAG = False
DBNAMEFLAG = False
DBVALUEFLAG = False
ITEMFLAG = False
ITEMFLAG = True
STATEFLAG = False
ENEMYFLAG = False
ARMORFLAG = False
WEAPONFLAG = False
SKILLFLAG = True
SKILLFLAG = False
def handleWOLF(filename, estimate):
@ -929,7 +929,7 @@ def searchDB(events, pbar, jobList, filename):
try:
for table in tableList:
# Grab NPCs
if table["name"] == "マップ選択画面" and NPCFLAG == True:
if table["name"] == "主人公ステータス" and NPCFLAG == True:
with open("translations.txt", "a", encoding="utf-8") as file:
if setData:
file.write(f"\n#Actors\n")
@ -939,7 +939,7 @@ def searchDB(events, pbar, jobList, filename):
# Parse
for j in range(len(dataList)):
# Name
if dataList[j].get("name") == "マップ":
if dataList[j].get("name") == "キャラ":
# Pass 1 (Grab Data)
if setData == False:
if dataList[j].get("value") != "":
@ -956,7 +956,7 @@ def searchDB(events, pbar, jobList, filename):
npcList[0].pop(0)
# Description
if dataList[j].get("name") == "NULL":
if dataList[j].get("name") == "肩書き":
# Pass 1 (Grab Data)
if setData == False:
if dataList[j].get("value") != "":
@ -1290,8 +1290,8 @@ def searchDB(events, pbar, jobList, filename):
dataList = item["data"]
# Parse
font = 20
for j in range(len(dataList)):
font = 24
# Name
if dataList[j].get("name") == "アイテム名":
jaString = dataList[j].get("value")
@ -1311,7 +1311,7 @@ def searchDB(events, pbar, jobList, filename):
itemList[0].pop(0)
# Description
if dataList[j].get("name") == "説明文[2行まで可]":
if dataList[j].get("name") == "NULL":
# Pass 1 (Grab Data)
if setData == False:
if dataList[j].get("value") != "":
@ -1328,7 +1328,7 @@ def searchDB(events, pbar, jobList, filename):
if dataList[j].get("value") != "":
# Textwrap
translatedText = itemList[1][0]
translatedText = textwrap.fill(translatedText, LISTWIDTH)
# translatedText = textwrap.fill(translatedText, LISTWIDTH)
# Font
if font:
@ -1339,7 +1339,7 @@ def searchDB(events, pbar, jobList, filename):
itemList[1].pop(0)
# Log
if dataList[j].get("name") == "使用時文章":
if dataList[j].get("name") == "使用時文章[戦](人名~":
# Pass 1 (Grab Data)
if setData == False:
if dataList[j].get("value") != "":
@ -1454,14 +1454,14 @@ def searchDB(events, pbar, jobList, filename):
armorList[1].pop(0)
# Grab Enemies
if table["name"] == "" and ENEMYFLAG == True:
if table["name"] == "キャラ個体データ" and ENEMYFLAG == True:
for enemy in table["data"]:
dataList = enemy["data"]
# Parse
for j in range(len(dataList)):
# Name
if dataList[j].get("name") == "":
if dataList[j].get("name") == "敵キャラ":
# Pass 1 (Grab Data)
if setData == False:
if dataList[j].get("value") != "":
@ -1492,7 +1492,10 @@ def searchDB(events, pbar, jobList, filename):
# Textwrap
translatedText = enemyList[1][0]
translatedText = textwrap.fill(translatedText, LISTWIDTH)
translatedText = font + translatedText
# Font
if font:
translatedText = f"\\f[{font}]{translatedText}"
# Set Data
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.
```
# Game Characters
ソフィー (Sophie) - Female
カタリナ (Katarina) - Female
師匠ドロシア (Master Dorothea) - Female
ギルド女性受付 (Guild Receptionist) - Female
娼館受付 (Brothel Receptionist) - Female
ドミ (Domi) - Unknown
姫ヶ崎エミリー (Emily Himegasaki) - Female
冒険者ジャック (Adventurer Jack) - Male
カボチャ女 (Pumpkin Woman) - Female
カボチャ男 (Pumpkin Man) - Male
エマえがお (Emma) - Female
ジーナ (Gina) - Female
諸葛霊孔明 (Zhuge Ling Kongming) - Male
Taro - Male
羽田 千紗 (Haneda Chisa) - Female
川村 芳乃 (Kawamura Yoshino) - Female
御小柴 朱梨 (Mikoshiba Shuri) - Female
早乙女 恭香 (Saotome Kyouka) - Female
夢園 蓮美 (Yumezono Hasumi) - Female
# Lewd Terms
マンコ (pussy)
@ -157,25 +150,5 @@ w ((lol))
』 (』)
# 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)
```