diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index 4cd8603..1804d84 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -45,7 +45,7 @@ FACENAME101 = False # Find Speakers in 101 Codes based on Face Name NAMES = False # Output a list of all the character names found BRFLAG = False # If the game uses
instead FIXTEXTWRAP = True # Overwrites textwrap -IGNORETLTEXT = False # Ignores all translated text. +IGNORETLTEXT = True # Ignores all translated text. MISMATCH = [] # Lists files that throw a mismatch error (Length of GPT list response is wrong) PBAR = None FILENAME = None @@ -83,9 +83,9 @@ POSITION = 0 LEAVE = False # Dialogue / Scroll / Choices (Main Codes) -CODE401 = False -CODE405 = False -CODE102 = False +CODE401 = True +CODE405 = True +CODE102 = True # Optional CODE101 = False # Turn this one when names exist in 101 @@ -320,7 +320,7 @@ def translateNote(event, regex, wrap=True): # translatedText = translatedText.replace("\n", "\\n") translatedText = translatedText.replace('"', "") - translatedText = translatedText.replace(' ', "_") + # translatedText = translatedText.replace(' ', "_") jaString = jaString.replace(initialJAString, translatedText) event["note"] = jaString i += 1 @@ -661,8 +661,8 @@ def searchNames(data, pbar, context): tokensResponse = translateNote(data[i], r"ADTs?:(.+?)>") totalTokens[0] += tokensResponse[0] totalTokens[1] += tokensResponse[1] - if "=前提スキル" in data[i]["note"]: - tokensResponse = translateNote(data[i], r"<習得ヘルプ=前提スキル:(.+?)>") + if "習得ヘルプ" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"<習得ヘルプ=(.+?)>") totalTokens[0] += tokensResponse[0] totalTokens[1] += tokensResponse[1] @@ -1553,258 +1553,38 @@ def searchCodes(page, pbar, jobList, filename): ## Event Code: 355 or 655 Scripts [Optional] if "c" in codeList[i] and (codeList[i]["c"] == 355 or codeList[i]["c"] == 655) and CODE355655 is True: jaString = codeList[i]["p"][0] + + patterns = { + "テキスト-": (r"テキスト-(.+)", "'"), + "logtxt = ": (r"logtxt\s=\s'(.+)'", "'"), + ".setNickname": (r'.setNickname\(\\?"(.+?)\\?"\)', "'"), + "_subject=": (r'_subject=(.+?)_', "'"), + "text =": (r'text\s=\s"(.+)"', '"'), + "ex_a_name": (r'ex_a_name\(\d+,"(.+)"\)', '"') + } - if "テキスト-" in jaString: - jaString = codeList[i]["p"][0] - regex = r"テキスト-(.+)" + for key, (regex, escape_char) in patterns.items(): + if key in jaString: + match = re.search(regex, jaString) + if match: + replaceString = match.group(1) + finalJAString = replaceString.replace("\u3000", "").strip() + + if finalJAString: + # Pass 1 + if setData == False: + list355655.append(finalJAString) - # Check Exist - match = re.search(regex, jaString) - if match: - replaceString = match.group(1) - finalJAString = replaceString + # Pass 2 + else: + # Grab and Replace + translatedText = list355655[0] + translatedText = re.sub(f'(?.*") + response = translateNoteOmitSpace(event, r"") totalTokens[0] += tokensResponse[0] totalTokens[1] += tokensResponse[1] + if "") + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] + if "sub_1" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"]+)", True) + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] + if "sub_2" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"]+)", True) + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] + if "sub_3" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"]+)", True) + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] + if "infowindow" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"", True) + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] + i += 1 else: @@ -786,7 +807,8 @@ def searchNames(data, pbar, context): data[j]["name"] = translatedNameBatch[0] translatedNameBatch.pop(0) if "description" in data[j] and data[j]["description"] != "": - data[j]["description"] = textwrap.fill(translatedDescriptionBatch[0], LISTWIDTH) + translatedDescriptionBatch[0] = textwrap.fill(translatedDescriptionBatch[0], LISTWIDTH) + data[j]["description"] = translatedDescriptionBatch[0] translatedDescriptionBatch.pop(0) # If Batch is empty. Move on. @@ -851,6 +873,7 @@ def searchCodes(page, pbar, jobList, filename): list108 = jobList[3] list356 = jobList[4] list357 = jobList[5] + list408 = jobList[6] setData = False else: list401 = [] @@ -859,6 +882,7 @@ def searchCodes(page, pbar, jobList, filename): list108 = [] list356 = [] list357 = [] + list408 = [] setData = True textHistory = [] match = [] @@ -1210,7 +1234,7 @@ def searchCodes(page, pbar, jobList, filename): # 1. Split translatedText by newlines lines = [line for line in translatedText.split('\n') if line.strip() != ""] - # 2. Set the first string to codeList[j]["p"] + # 2. Set the first string to codeList[j]["parameters"] codeList[j]["parameters"] = [lines[0]] # 3. Make copies for each additional line and insert them @@ -1237,7 +1261,7 @@ def searchCodes(page, pbar, jobList, filename): ## Event Code: 122 [Set Variables] if "code" in codeList[i] and codeList[i]["code"] == 122 and CODE122 is True: # This is going to be the var being set. (IMPORTANT) - if codeList[i]["parameters"][0] not in list(range(0, 1200)): + if codeList[i]["parameters"][0] not in list(range(0, 99999)): i += 1 continue @@ -1254,14 +1278,14 @@ def searchCodes(page, pbar, jobList, filename): continue # Definitely don't want to mess with files - if 'gameV' in jaString or '_' in jaString: + if 'gameV' in jaString or '_' in jaString or '"[' in jaString: i += 1 continue - # Avoid anything not quoted - if '\"' not in jaString: - i += 1 - continue + # # Avoid anything not quoted + # if '\"' not in jaString: + # i += 1 + # continue # Validate Japanese Text if not re.search(LANGREGEX, jaString): @@ -1293,6 +1317,9 @@ def searchCodes(page, pbar, jobList, filename): for char in charList: translatedText = translatedText.replace(char, "") + # Force 4 Escapes + translatedText = re.sub(r'(? 0: # Translate text = matchList[0] @@ -2115,6 +2011,7 @@ def searchCodes(page, pbar, jobList, filename): # EOF list401TL = [] + list408TL = [] list122TL = [] list356TL = [] list357TL = [] @@ -2188,12 +2085,23 @@ def searchCodes(page, pbar, jobList, filename): if filename not in MISMATCH: MISMATCH.append(filename) + # 408 + if len(list408) > 0: + response = translateGPT(list408, "", True) + list408TL = response[0] + totalTokens[0] += response[1][0] + totalTokens[1] += response[1][1] + if len(list408TL) != len(list408): + with LOCK: + if filename not in MISMATCH: + MISMATCH.append(filename) + # Start Pass 2 if setData: searchCodes( page, pbar, - [list401TL, list122TL, list355655TL, list108TL, list356TL, list357TL], + [list401TL, list122TL, list355655TL, list108TL, list356TL, list357TL, list408TL], filename, ) @@ -2354,6 +2262,10 @@ Translate 'Taroを倒した!' as 'Taro was defeated!'", noteResponse = translateNote(state, r"") totalTokens[0] += noteResponse[0] totalTokens[1] += noteResponse[1] + if "") + totalTokens[0] += noteResponse[0] + totalTokens[1] += noteResponse[1] # Count totalTokens totalTokens[0] += nameResponse[1][0] if nameResponse != "" else 0 diff --git a/modules/wolf.py b/modules/wolf.py index 7bee0c4..2f6d07b 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -85,8 +85,8 @@ CODE101 = False CODE102 = False # Set String (Fragile but necessary) -CODE122 = True -CODE150 = False +CODE122 = False +CODE150 = True # Other CODE210 = False @@ -265,11 +265,13 @@ def searchCodes(events, pbar, jobList, filename): stringList = jobList[0] list210 = jobList[1] list300 = jobList[2] + list150TL = jobList[3] # Add this line setData = True else: stringList = [] list210 = [] list300 = [] + list150TL = [] # Add this line setData = False # Other @@ -300,7 +302,7 @@ def searchCodes(events, pbar, jobList, filename): while i < len(codeList): ### Event Code: 101 Message if codeList[i]["code"] == 101 and CODE101 == True: - speakerRegex = r"@\d+\r?\n(.*):\r?\n" # Default: r"@\d+\r?\n(.*):\r?\n" + speakerRegex = r"^(.+?)\n" # Default: r"@\d+\r?\n(.*):\r?\n" textRegex = r"@?\d*\r?\n?\u3000*([\w\W]+)\r?\n?" # Default: r"@?\d*\r?\n?\u3000*([\w\W]+)\r?\n?" # Grab String @@ -308,7 +310,7 @@ def searchCodes(events, pbar, jobList, filename): speaker = "" # Grab Speaker - if ":\n" in jaString or ":\r\n" in jaString: + if "\n" in jaString: match = re.search(speakerRegex, jaString) if match: # TL Speaker @@ -370,9 +372,13 @@ def searchCodes(events, pbar, jobList, filename): choiceList.append(jaChoiceList[j]) # Translate + if 'jaString' in locals(): + choiceString = f"Previous Line: {jaString}\n\nReply with the {LANGUAGE} translation of the dialogue choice" + else: + choiceString = f"Reply with the {LANGUAGE} translation of the dialogue choice" response = translateGPT( choiceList, - f"Reply with the {LANGUAGE} translation of the dialogue choice", + choiceString, True, ) translatedChoiceList = response[0] @@ -439,7 +445,7 @@ def searchCodes(events, pbar, jobList, filename): originalString = jaString # Remove Textwrap - jaString = jaString.replace('\n', ' ') + # jaString = jaString.replace('\n', ' ') # Translate Conversations if ":Nothing" in jaString: @@ -497,14 +503,15 @@ def searchCodes(events, pbar, jobList, filename): totalTokens[1] += response[1][1] # Textwrap - translatedText = textwrap.fill(translatedText, 30) + # translatedText = textwrap.fill(translatedText, 30) # Set String codeList[i]["stringArgs"][0] = codeList[i]["stringArgs"][0].replace(originalString, translatedText) ### Event Code: 150 Picture String if codeList[i]["code"] == 150 and CODE150 == True: - if "stringArgs" in codeList[i] and len(codeList[i]["stringArgs"]) > 0: + if "stringArgs" in codeList[i] and len(codeList[i]["stringArgs"]) > 0: + font150 = "\\f[8]" # Grab String jaString = re.search(r"^\n?(.*)\n?$", codeList[i]["stringArgs"][0]) if jaString: @@ -512,9 +519,14 @@ def searchCodes(events, pbar, jobList, filename): else: jaString = codeList[i]["stringArgs"][0] + # Japanses Text Only + if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9]+", jaString): + i += 1 + continue + # Remove Textwrap - jaString = jaString.replace("\n", " ") - jaString = jaString.replace("\r", "") + # jaString = jaString.replace("\n", " ") + # jaString = jaString.replace("\r", "") # Translate Other Strings [Specific Files Only] if ( @@ -523,24 +535,25 @@ def searchCodes(events, pbar, jobList, filename): and "_" not in jaString and '",' not in jaString and "/" not in jaString + and ">" not in jaString + and "<" not in jaString ): - # Japanese Text Only - if re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9]+", jaString): - # Translate - response = translateGPT( - jaString, - f"Reply with the {LANGUAGE} translation of the text", - True, - ) - translatedText = response[0] - totalTokens[0] += response[1][0] - totalTokens[1] += response[1][1] + # Pass 1 (Save Text to List) + if not setData: + list150TL.append(jaString) + + # Pass 2 (Set Text) + else: + translatedText = list150TL[0] # Textwrap - translatedText = textwrap.fill(translatedText, WIDTH) + # translatedText = textwrap.fill(translatedText, WIDTH) - # Set String - codeList[i]["stringArgs"][0] = translatedText + # Set String with font formatting + codeList[i]["stringArgs"][0] = re.sub(r'\\f\[(\d+)\]', lambda x: f'\\f[{int(x.group(1))-2}]', translatedText) + + # Pop processed item + list150TL.pop(0) ### Event Code: 300 Common Events if codeList[i]["code"] == 300 and CODE300 == True and "stringArgs" in codeList[i] and len(codeList[i]["stringArgs"]) > 1: @@ -750,10 +763,37 @@ def searchCodes(events, pbar, jobList, filename): else: setData = True - # Pass 2 - if setData: + # 150 List + if len(list150TL) > 0: + # Progress Bar + pbar.total = len(list150TL) + pbar.refresh() + + # Translate + response = translateGPT( + list150TL, + textHistory, + True, + ) + stringList150TL = response[0] + totalTokens[0] += response[1][0] + totalTokens[1] += response[1][1] + + # Check Mismatch + if len(stringList150TL) != len(list150TL): + with LOCK: + if filename not in MISMATCH: + MISMATCH.append(filename) + else: + list150TL = stringList150TL + setData = True + + # Update jobList before recursive call + if setData == True: stringList = [] - searchCodes(events, pbar, [stringListTL, list210TL, list300TL], filename) + jobList = [stringListTL, list210TL, list300TL, list150TL] # Add list150TL + searchCodes(events, pbar, jobList, filename) + else: # Set Data events = codeList @@ -974,7 +1014,7 @@ def searchDB(events, pbar, jobList, filename): # Pass 2 (Set Data) else: if dataList[j].get("value") != "": - dataList[j].update({"value": choiceList[0][0]}) + dataList[j].update({"value": optionsList[0][0]}) optionsList[0].pop(0) # Description diff --git a/vocab.txt b/vocab.txt index 99cfca3..34bcfb1 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,153 +1,19 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters -ネイビス (Neibis) - Male -ビダール (Bidal) - Male -エルニン (Elnin) - Female -メマ (Mema) - Female -教皇 (Pope) - Female -ボルカヌス (Volcanus) - Male -トリスリタン (Trisritan) - Female -ノビッサ (Novissa) - Male -ルー (Rue) - Female -エルニン (Elnin) - Female -ギロ (Giro) - Female -クスミ (Kusumi) - Female -パラコーン (Paracon) - Female -チヤ (Chiya) - Female -コアンタ (Koanta) - Female -ハイプリ神官長 (High Priest Haipri) - Female -メマ (Mema) - Female -ハノン (Hanon) - Female -ミッシェル (Michelle) - Female -エクスキューショナー (Executioner) - Female -オーガトゥース (Ogretooth) - Female -ミステルテイン (Misteltein) - Female -シャシー (Shashi) - Female -ルセーダ (Luceda) - Female -プリン (Purin) - Female -アンベル (Amber) - Female -アンカープ (Anchorp) - Female -ヨルク (Yoruku) - Female -ハーター (Harter) - Female -コキューン (Cocoon) - Male -ビルドルフ - Male -ゼロジー (Zero-G) - Male -ベルマ (Belma) - Male -ヴォルゼブ (Volzeb) - Male - -# Enemies (Mostly Female) -透明君 (Transparent-kun) -ゼリン (Zerin) -ミリア (Milia) -マヤ (Maya) -ミステルテイン (Misteltein) -怪しい二人組 (Suspicious Duo) -ガレオン (Galion) -グリフォン (Griffon) -キッスプラント (Kiss Plant) -ゴーレム (Golem) -所属不明(ゴーグル) (Unknown Affiliation (Goggles)) -所属不明(マスク) (Unknown Affiliation (Mask)) -憲兵 (Military Police) -トニオ (Tonio) -ロベルタ (Roberta) -アモーレ (Amore) -ビタラ (Vitata) -軍隊砂漠蟻 (Desert Army Ant) -盗賊 (Thief) -鳥人間(槍) (Birdman (Spear)) -鳥人間 (Birdman) -ガーツ (Gartz) -アイスアー (Ice Arrow) -フリーズゴーレム (Freeze Golem) -ハーティー (Harty) -トリスリタン (Trisritan) -ハノン (Hanon) -マグゼリン (Magzellin) -バーストリアー (Burstrier) -インプ (Imp) -フェーニ (Feny) -トールドラゴン (Thor Dragon) -イフリート (Ifrit) -ターゼリン (Tazerin) -ハーパキャット (Harpercat) -ヨヨ (Yoyo) -野良ガーディアン (Stray Guardian) -グルームの牙 (Groom's Fang) -ハプリコーン (Harpricorn) -聖十字隊 (Holy Cross Squad) -フレイア教徒 (Freya Cultist) -プリースト (Priest) -フレイア神官 (Freya Priest) -チヤ (Chiya) -コアンタ (Koanta) -パラコーン (Paracon) -ムラタン (Muratan) -コアハンター (Core Hunter) -イヴ (Eve) -レタ (Leta) -ダークレタ (Dark Leta) -ババヤン (Babayan) -沼の魔女 (Swamp Witch) -マヴィチャ (Mavicha) -ビヨンド (Beyond) -セイバーガーディアン (Saber Guardian) -アーチャーガーディアン (Archer Guardian) -エクスキューショナー (Executioner) -オーガトゥース (Orgatous) -ギロ (Giro) -ドイレン=ベッシェ (Doiren=Besshe) -エレメェス=ショーサ (Eremees=Shosa) -ローレンス=ランブル (Lawrence=Rumble) -グレムリン (Gremlin) -ドゲザエ (Dogezae) -心を失った者 (The Heartless) -エキューオ (Equio) -エルニン (Elnin) -グルームの夜 (Gloom's Night) -ラギッドグール (Ragged Ghoul) -デスプードル (Death Poodle) -グールデストロイ (Ghoul Destroyer) -ヴァンシィ (Banshee) -ネクロマンサー (Necromancer) -ヘルチョンチョニ (Hell Chonchoni) -羽蟲の魔物 (Winged Insect Monster) -堕ちた大神官フィーヴァム (Fallen High Priest Fivam) -ヴィージヨ (Vijyo) -ヴェルセブブ (Versebub) -親衛隊トニオ (Royal Guard Tonio) -親衛隊ロベルタ (Royal Guard Roberta) -親衛隊アモーレ (Royal Guard Amore) -女王親衛隊 (Queen's Royal Guard) -マヤゴールド (Mayagold) -クィーンハーピー (Queen Harpy) -イクリプス (Eclipse) -マスクドフレイア (Masked Freya) -クルトラナッソス (Cultranassus) -サイドワインダー (Sidewinder) -マーリン (Merlin) -トレント=イニー (Trent=Inny) -アストロス (Astros) -タンクウガ (Tankuga) -ヴィーゴニク (Vigonik) -スラムのゴロツキ (Slum Thug) -スライム娘 (Slime Girl) -ジェネラルマーメイド (General Mermaid) -ヴァルキリー (Valkyrie) -防衛装置 (Defense Device) -ヘルヴァンシー (Helvancy) -マーガレット=ソニア (Margaret=Sonia) -ガーディアン改修型 (Modified Guardian) -イグゼニム (Igzenim) -アビスガード (Abyss Guard) -ルカ=ドッペル (Luca=Doppel) -シグルドリーヴァ (Sigurdrieva) -オニール (O'Neill) -訓練兵たち (Trainees) -没オニール (Dead O'Neill) -没オニール使う枠 (Dead O'Neill Slot) -聖十字隊副隊長 (Holy Cross Squad Vice-Captain) +姫野 彩羽 (Himeno Iroha) - Female +朝樹 (Asaki) - Male +リリィ (Lily) - Female +佐井 民太郎 (Sai Mintaro) - Male +鐘尾原 真久 (Kaneobara Maku) - Male +岡根 梨 (Okane Nashi) - Female +藍場 結奈 (Aiba Yuna) - Female +スーティ (Suti) - Female +収集家レティシア (Collector Leticia) - Female +アルフ (Alf) - Male +カドーナ (Kadona) - Female +保田区くん (Potaku-kun) - Male +衿澄 雫 (Erisumi Shizuku) - Female # Lewd Terms マンコ (pussy) @@ -241,6 +107,8 @@ ME 音量 (ME Volume) 魂 (Soul) 巫女 (Shrine Maiden) 刀 (Sword) +龍神神社 (Dragon God Shrine) + # Demons/Angels/Monsters 悪魔 (Devil) @@ -267,6 +135,7 @@ ME 音量 (ME Volume) 幽鬼 (Revenant) デーモン (Daemon) ローバー (Roper) +夢魔 (Succubus) # Other w ((lol)) @@ -275,21 +144,16 @@ w ((lol)) 』 (』) # Game Specific -フレイア大神殿 (Freya Grand Temple) -スードリ草原 (Sudri Grasslands) -ポルナトル渓谷 (Polnator Valley) -ホテル・ドラゴンエンペラー (Hotel Dragon Emperor) -バレルゼン路地裏 (Barrelzen Back Alley) -ビルドルフの部屋 (Bildolf's Room) -ベインスゥ・酒場 (Veins Tavern) -ムジョルニア火山01 (Mujornia Volcano 01) -ラ・フェール歓楽街 (Ra Feele Pleasure District) -ジェマの部屋 (Jema's Room) -ベルマの研究室 (Belma's Laboratory) -エユタヤー (Eyutaya) -ヴォルゼブの部屋 (Wolfchev's Room) -モスフィア島 (Mosfia Island) -バー・止まり木 (Bar・Perch) -バー・スクサマッド (Bar・Sukusamadd) -ラフェルムーン (Rafel Moon) +すけモン (Sukemon) +夢見町 (Dream Town) +夢見学 (Dream Academy) +龍神神社 (Dragon God Shrine) +鐘尾原 (Kaneohara) +カドーナ (Kadona) +助平の湯 (Lewd Bath) +リーゴ (Ligo) +サキュバンク (Succubank) +ジャーク堂書店 (Jerkdo Bookstore) +風紀委員は女淫魔の夢を見るか? (Do Disciplinary Committee Members Dream of Succubi?) + ``` \ No newline at end of file