From 4e57093dfd3905d5278bcc360e529f1a5a55128c Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Thu, 19 Dec 2024 18:47:24 -0600 Subject: [PATCH] Fix single string --- modules/csv.py | 30 +++++++++++++-------- modules/json.py | 30 +++++++++++++-------- modules/kirikiri.py | 30 +++++++++++++-------- modules/nscript.py | 30 +++++++++++++-------- modules/regex.py | 30 +++++++++++++-------- modules/renpy.py | 30 +++++++++++++-------- modules/rpgmakerace.py | 30 +++++++++++++-------- modules/rpgmakermvmz.py | 47 ++++++++++++++++++-------------- modules/rpgmakerplugin.py | 30 +++++++++++++-------- modules/text.py | 30 +++++++++++++-------- modules/tyrano.py | 30 +++++++++++++-------- modules/wolf.py | 30 +++++++++++++-------- modules/wolf2.py | 30 +++++++++++++-------- vocab.txt | 56 +++++++++++++++++++++++++++++++++------ 14 files changed, 303 insertions(+), 160 deletions(-) diff --git a/modules/csv.py b/modules/csv.py index 0fe6272..6ded874 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -419,7 +419,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -434,7 +437,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -544,15 +550,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/json.py b/modules/json.py index 42f2a0f..691b4fc 100644 --- a/modules/json.py +++ b/modules/json.py @@ -360,7 +360,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -375,7 +378,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -485,15 +491,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/kirikiri.py b/modules/kirikiri.py index 66f2ab1..1a9098b 100644 --- a/modules/kirikiri.py +++ b/modules/kirikiri.py @@ -403,7 +403,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -418,7 +421,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -528,15 +534,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/nscript.py b/modules/nscript.py index 12a2d85..ae324e1 100644 --- a/modules/nscript.py +++ b/modules/nscript.py @@ -419,7 +419,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -434,7 +437,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -544,15 +550,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/regex.py b/modules/regex.py index 04662d4..ccd5142 100644 --- a/modules/regex.py +++ b/modules/regex.py @@ -419,7 +419,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -434,7 +437,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -544,15 +550,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/renpy.py b/modules/renpy.py index 35e1b9a..9170afe 100644 --- a/modules/renpy.py +++ b/modules/renpy.py @@ -343,7 +343,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -358,7 +361,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -468,15 +474,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index f807bd0..223119b 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -2475,7 +2475,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -2490,7 +2493,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -2600,15 +2606,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 3c5a676..deaff9f 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -71,7 +71,7 @@ CODE405 = True CODE102 = True # 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 @@ -617,10 +617,8 @@ def searchNames(data, pbar, context): # Messages number = 1 while number < 5: - if f"message{number}" in data[i]: - if len(data[i][f"message{number}"]) > 0 and data[i][f"message{number}"][ - 0 - ] in ["は", "を", "の", "に", "が"]: + if f"message{number}" in data[i] and data[i][f"message{number}"]: + if data[i][f"message{number}"][0] in ["は", "を", "の", "に", "が"]: msgResponse = translateGPT( "Taro" + data[i][f"message{number}"], "reply with only the gender neutral " @@ -680,10 +678,11 @@ def searchNames(data, pbar, context): totalTokens[1] += response[1][1] # Nickname - response = translateGPT(nicknameList, newContext, True) - translatedNicknameBatch = response[0] - totalTokens[0] += response[1][0] - totalTokens[1] += response[1][1] + if nicknameList: + response = translateGPT(nicknameList, newContext, True) + translatedNicknameBatch = response[0] + totalTokens[0] += response[1][0] + totalTokens[1] += response[1][1] # Profile response = translateGPT(profileList, "", True) @@ -2464,7 +2463,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -2479,7 +2481,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -2589,15 +2594,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/rpgmakerplugin.py b/modules/rpgmakerplugin.py index 6cbf698..799a005 100644 --- a/modules/rpgmakerplugin.py +++ b/modules/rpgmakerplugin.py @@ -334,7 +334,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -349,7 +352,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -459,15 +465,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/text.py b/modules/text.py index 8f4c84b..12bef1d 100644 --- a/modules/text.py +++ b/modules/text.py @@ -334,7 +334,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -349,7 +352,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -459,15 +465,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/tyrano.py b/modules/tyrano.py index e9ed2c9..f8ff4d5 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -410,7 +410,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -425,7 +428,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -535,15 +541,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/wolf.py b/modules/wolf.py index 0f8b555..50e405a 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -2272,7 +2272,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -2287,7 +2290,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -2397,15 +2403,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/modules/wolf2.py b/modules/wolf2.py index ac93d66..c113123 100644 --- a/modules/wolf2.py +++ b/modules/wolf2.py @@ -377,7 +377,10 @@ Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{ {VOCAB}\n\ " ) - user = f"```json\n{subbedT}\n```" + if format == "json": + user = f"```json\n{subbedT}\n```" + else: + user = subbedT return system, user @@ -392,7 +395,10 @@ def translateText(system, user, history, penalty, format, model=MODEL): msg.append({"role": "system", "content": history}) # Response Format - responseFormat = {"type": "json_object"} + if format == "json": + responseFormat = {"type": "json_object"} + else: + responseFormat = {"type": "text"} # Content to TL msg.append({"role": "user", "content": f"{user}"}) @@ -502,15 +508,17 @@ def translateGPT(text, history, fullPromptFlag): for index, tItem in enumerate(tList): # Before sending to translation, if we have a list of items, add the formatting - if not isinstance(tItem, list): - tItem = [tItem] - for j in range(len(tItem)): - if not tItem[j]: - tItem[j] = tItem[j].replace("", "Placeholder Text") - payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} - payload = json.dumps(payload, indent=4, ensure_ascii=False) - varResponse = [payload, []] - subbedT = varResponse[0] + if isinstance(tItem, list): + for j in range(len(tItem)): + if not tItem[j]: + tItem[j] = tItem[j].replace("", "Placeholder Text") + payload = {f"Line{i+1}": string for i, string in enumerate(tItem)} + payload = json.dumps(payload, indent=4, ensure_ascii=False) + varResponse = [payload, []] + subbedT = varResponse[0] + else: + varResponse = [tItem, []] + subbedT = varResponse[0] # Things to Check before starting translation if not re.search(r"[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9\uFF61-\uFF9F]+", subbedT): diff --git a/vocab.txt b/vocab.txt index 358f166..cd2f43f 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,14 +1,10 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters -ルカミラ ハル ロッシュ (Lukamilla Harre Roche) - Female -マリアーヌ ローエン グリン (Marianne Roen Green) - Female -リアン (Rianne) - Female -スカーレット ルンベルク (Scarlet Lumberg) - Female -ソフィア (Sofia) - Female -アグファス ブロウニン (Agfas Blonin) - Male -マルック スタンレー (Marc Stanley) - Male -モノキオス (Monokios) - Male +エレッタ (Eretta) - Female +セッカ (Sekka) - Female +新宮寧々 (Nene Shingu) - Female +辰野伊吹 (Ibuki Tatsuno) - Female # Lewd Terms マンコ (pussy) @@ -93,4 +89,48 @@ w ((lol)) 巫女 (Shrine Maiden) コイツ (this bastard) メナスフィア (Menacephere) + +# Armor +ガードストーン (Guard Stone) +ガードリング (Guard Ring) +パワーストーン (Power Stone) +パワーリング (Power Ring) +スピードストーン (Speed Stone) +スピードリング (Speed Ring) +ラッキーストーン (Lucky Stone) +ラッキーリング (Lucky Ring) +マジカルストーン (Magical Stone) +マジカルリング (Magical Ring) +シューターストーン (Shooter Stone) +シューターリング (Shooter Ring) + +# Classes +キュバリエエレッタ (Cavalier Eretta) + +#Enemies +ガーゴットン (Gargoton) +スライム (Slime) +スライム(エロなし) (Slime (No Lewd)) +群体スライム(中ボス) (Swarm Slime (Mid-Boss)) +スライム(黄) (Slime (Yellow)) +ボスウナズ (Boss Unaz) +スライム(道中エロ補助用) (Slime (On the Way for Lewd Support)) +スライム(取り巻き) (Slime (Minion)) +ゴブリンリーダー (Goblin Leader) +ゴブリンシャーマン (Goblin Shaman) +ゴブリンソルジャー (Goblin Soldier) +ゴブリン(取り巻き) (Goblin (Minion)) +オーク (Orc) +ボストロ (Bostro) +アイリス (Iris) +アラクネ (Arachne) +テレビフレーム (TV Frame) +コカトリス (Cockatrice) +シュトリア (Shtoria) +シュトリアビット (Shtoria Bit) +シュトリアビット2 (Shtoria Bit 2) +ボスウナズ (Boss Unaz) + +# Locations +ハレイシア (Haleisia) ``` \ No newline at end of file