diff --git a/modules/csv.py b/modules/csv.py index 4ebd279..28b2667 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -376,35 +376,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/images.py b/modules/images.py index 3ab6248..dcffb3b 100644 --- a/modules/images.py +++ b/modules/images.py @@ -68,8 +68,8 @@ def handleImages(folderName, estimate): translatedData = openFiles(f"files/{folderName}") # Custom Names - # customList = [[], []] - # customList = processImagesDir('Custom', customList) + customList = [[], []] + customList = processImagesDir('Custom', customList) # Write Strings to Images if not ESTIMATE: @@ -84,9 +84,9 @@ def handleImages(folderName, estimate): translatedList[i], dimensionsList[i][0], dimensionsList[i][1] ) image.save( - rf"translated/{folderName}/{translatedList[i]}.png", quality=100 + rf"translated/{folderName}/{customList[0][0]}.png", quality=100 ) - # customList[0].pop(0) + customList[0].pop(0) except Exception as e: PBAR.write(f"{translatedList[i]}: {str(e)}") # Ignore Error @@ -189,7 +189,7 @@ def getFontSize(text, image_width, image_height, font_path): (0, 0), text, font=font ) text_width = text_bbox[2] - text_bbox[0] - text_height = text_bbox[3] - text_bbox[1] + 10 + text_height = text_bbox[3] - text_bbox[1] if text_width <= image_width and text_height <= image_height: return font_size @@ -222,9 +222,9 @@ def stringToImage( # Calculate the size of the text to center it text_bbox = draw.textbbox((0, 0), text, font=font) text_width = text_bbox[2] - text_bbox[0] - text_height = text_bbox[3] - text_bbox[1] + text_height = text_bbox[3] - text_bbox[1] + 20 x = 0 - y = 0 + y = (scaled_height - text_height) // 2 # Draw the text on the image draw.text((x, y), text, font=font, fill=(255, 255, 255, 255)) @@ -311,35 +311,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/lune.py b/modules/lune.py index e28a4e6..996ce91 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -316,35 +316,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/nscript.py b/modules/nscript.py index fc15f20..3076013 100644 --- a/modules/nscript.py +++ b/modules/nscript.py @@ -384,35 +384,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index 610ef25..1a0684b 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -2425,35 +2425,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 128b81c..df7fa5f 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -72,7 +72,7 @@ CODE405 = False CODE102 = False # Optional -CODE101 = False # Turn this one when names exist in 101 +CODE101 = True # Turn this one when names exist in 101 CODE408 = False # Warning, translates comments and can inflate costs. # Variables @@ -80,7 +80,7 @@ CODE122 = False # Other CODE355655 = False -CODE357 = True +CODE357 = False CODE657 = False CODE356 = False CODE320 = False @@ -1509,10 +1509,12 @@ def searchCodes(page, pbar, jobList, filename): translatedText = translatedText.replace(char, "") # Textwrap - # translatedText = textwrap.fill(translatedText, LISTWIDTH) - # translatedText = translatedText.replace("- ", "-") - # if acExist: - # translatedText = f'\\ac {translatedText.replace('\n', '\n\\ac ')}' + translatedText = textwrap.fill(translatedText, WIDTH) + translatedText = translatedText.replace("- ", "-") + + # Center Text + if acExist: + translatedText = f'\\ac {translatedText.replace('\n', '\n\\ac ')}' # Set codeList[i]["parameters"][3][argVar] = translatedText @@ -2503,36 +2505,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", - True, + False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - response[0] = response[0].replace("Speaker: ", "") - - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] @@ -2755,7 +2755,6 @@ def translateGPT(text, history, fullPromptFlag): continue # Translating - logFile.write(f'Input:\n{subbedT}\n') response = translateText(system, user, history, 0.05, format) translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens @@ -2782,6 +2781,7 @@ def translateGPT(text, history, fullPromptFlag): extractedTranslations ): mismatch = True # Just here for breakpoint + logFile.write(f'Input:\n{subbedT}\n') logFile.write(f'Output:\n{translatedText}\n') # Set if no mismatch diff --git a/modules/rpgmakerplugin.py b/modules/rpgmakerplugin.py index 0f70e2b..5335edc 100644 --- a/modules/rpgmakerplugin.py +++ b/modules/rpgmakerplugin.py @@ -289,35 +289,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/wolf.py b/modules/wolf.py index b3eeb3b..9f9f392 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -963,7 +963,7 @@ def searchDB(events, pbar, jobList, filename): scenarioList[2].pop(0) # Grab Items - if table["name"] == "モンスター図鑑" and ITEMFLAG == True: + if table["name"] == "mNPC管理" and ITEMFLAG == True: with open("translations.txt", "a", encoding="utf-8") as file: for item in table["data"]: dataList = item["data"] @@ -991,9 +991,9 @@ def searchDB(events, pbar, jobList, filename): itemList[0].pop(0) # Description 1 (You are my specialz) - if dataList[j].get("name") == "説明文": + if dataList[j].get("name") == "セリフ_交換成立": # Clean String - fontSize = 14 + fontSize = 24 translatedText = "" cleanedList = formatDramon(dataList[j].get("value")) for str in cleanedList: @@ -1053,7 +1053,7 @@ def searchDB(events, pbar, jobList, filename): dataList[j].update({"value": translatedText}) # Description 2 (You are my specialz) - if dataList[j].get("name") == "NULL": + if dataList[j].get("name") == "セリフ_素材が足りない": # Clean String fontSize = 24 translatedText = "" @@ -1115,7 +1115,7 @@ def searchDB(events, pbar, jobList, filename): dataList[j].update({"value": translatedText}) # Description 3 (You are my specialz) - if dataList[j].get("name") == "NULL": + if dataList[j].get("name") == "セリフ_": # Clean String fontSize = 24 translatedText = "" @@ -1773,36 +1773,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", - True, + False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - response[0] = response[0].replace("Speaker: ", "") - - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/modules/wolf2.py b/modules/wolf2.py index 6652ffc..4acbf0b 100644 --- a/modules/wolf2.py +++ b/modules/wolf2.py @@ -336,35 +336,34 @@ def getSpeaker(speaker): case "": return ["", [0, 0]] case _: - # Store Speaker - if speaker not in str(NAMESLIST): + # Find Speaker + for i in range(len(NAMESLIST)): + if speaker == NAMESLIST[i][0]: + return [NAMESLIST[i][1], [0, 0]] + + # Translate and Store Speaker + response = translateGPT( + f'Speaker: {speaker}', + "Reply with the " + LANGUAGE + " translation of the NPC name.", + True, + ) + response[0] = response[0].title() + response[0] = response[0].replace("'S", "'s") + response[0] = response[0].replace("Speaker: ", "") + + # Retry if name doesn't translate for some reason + if re.search(r"([a-zA-Z??])", response[0]) == None: response = translateGPT( - speaker, + f'Speaker: {speaker}', "Reply with the " + LANGUAGE + " translation of the NPC name.", False, ) response[0] = response[0].title() response[0] = response[0].replace("'S", "'s") - # Retry if name doesn't translate for some reason - if re.search(r"([a-zA-Z??])", response[0]) == None: - response = translateGPT( - speaker, - "Reply with the " + LANGUAGE + " translation of the NPC name.", - False, - ) - response[0] = response[0].title() - response[0] = response[0].replace("'S", "'s") - - speakerList = [speaker, response[0]] - NAMESLIST.append(speakerList) - return response - # Find Speaker - else: - for i in range(len(NAMESLIST)): - if speaker == NAMESLIST[i][0]: - return [NAMESLIST[i][1], [0, 0]] - + speakerList = [speaker, response[0]] + NAMESLIST.append(speakerList) + return response return [speaker, [0, 0]] diff --git a/vocab.txt b/vocab.txt index 2850669..cf7041a 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,50 +1,13 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters -ロラン (Roland) - Male\n\ -リュカ (Ryuka) - Male\n\ -レックス (Rex) - Male\n\ -タバサ (Tabasa) - Female\n\ -アルス (Ars) - Male\n\ -アマカラ (Amakara) - Male\n\ -エリー (Eri) - Female\n\ -リオ (Rio) - Female\n\ -サマル (Samal) - Male\n\ -ムーン (Moon) - Female\n\ -アリーナ (Arina) - Female\n\ -クリフト (Cliff) - Male\n\ -マーニャ (Manya) - Female\n\ -ミネア (Minea) - Female\n\ -デボラ (Debora) - Female\n\ -ビアンカ (Bianca) - Female\n\ -フローラ (Flora) - Female\n\ -バーバラ (Barbara) - Female\n\ -ミレーユ (Mireyu) - Female\n\ -アイラ (Aira) - Female\n\ -フォズ (Foz) - Female\n\ -マリベル (Maribel) - Female\n\ -ククール (Kukool) - Male\n\ -ゲルダ (Gerda) - Female\n\ -ゼシカ (Jessica) - Female\n\ -ヤンガス (Yangus) - Male\n\ -ラヴィエル (Raviel) - Female\n\ -セティア (Setia) - Female\n\ -ダイ (Dai) - Male\n\ -ヒュンケル (Hyunckel) - Male\n\ -ポップ (Pop) - Male\n\ -マァム (Maam) - Female\n\ -レオナ (Leona) - Female\n\ -アステア (Astea) - Female\n\ -イヨ (Iyo) - Female\n\ -ジャガン (Jagan) - Male\n\ -ヤオ (Yao) - Female\n\ -デイジィ (Daisy) - Female\n\ -バイシュン (Baishun) - Male\n\ -ブライ (Buraimu) - Male\n\ -ハッサン (Hassan) - Male\n\ -アロマ (Aroma) - Female\n\ -ピッケ (Pikke) - Female\n\ -ドラオ (Dorao) - Male\n\ +天之 みなか (Minaka Amayuki) - Female +御祖シターテル (Shitateru Miono) - Female +雨野 若姫 (Wakahime Amano) - Female +火野 円真 (Madoka Hino) - Female +玲原 導子 (Michiko Reihara) - Female +弓削 佐保 (Saho Yuge) - Female +鹿ヶ壺 伊佐 (Isa Kagatsubo) - Female # Lewd Terms マンコ (pussy) @@ -113,4 +76,8 @@ ME 音量 (ME Volume) 鬼 (Oni) ローバー (Roper) w (lol) +方相氏 (Housoushi) +天照大神おわす (Amaterasu Omikami) +月夜見尊お (Tsukuyomi no Mikoto) +辟邪の半陽 (Half Sun of Bixie) ``` \ No newline at end of file