Make setString a batch
This commit is contained in:
parent
aa2e28e247
commit
8abc5b3946
2 changed files with 48 additions and 58 deletions
103
modules/wolf.py
103
modules/wolf.py
|
|
@ -266,6 +266,7 @@ def searchCodes(events, pbar, jobList, filename):
|
||||||
list300 = jobList[2]
|
list300 = jobList[2]
|
||||||
list150 = jobList[3]
|
list150 = jobList[3]
|
||||||
list250 = jobList[4]
|
list250 = jobList[4]
|
||||||
|
list122 = jobList[5]
|
||||||
setData = True
|
setData = True
|
||||||
else:
|
else:
|
||||||
stringList = []
|
stringList = []
|
||||||
|
|
@ -273,6 +274,7 @@ def searchCodes(events, pbar, jobList, filename):
|
||||||
list300 = []
|
list300 = []
|
||||||
list150 = []
|
list150 = []
|
||||||
list250 = []
|
list250 = []
|
||||||
|
list122 = []
|
||||||
setData = False
|
setData = False
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
|
@ -445,68 +447,37 @@ def searchCodes(events, pbar, jobList, filename):
|
||||||
originalString = jaString
|
originalString = jaString
|
||||||
|
|
||||||
# Remove Textwrap
|
# Remove Textwrap
|
||||||
# jaString = jaString.replace('\n', ' ')
|
jaString = jaString.replace("\r", "")
|
||||||
|
jaString = jaString.replace("\n", " ")
|
||||||
|
|
||||||
# Translate Conversations
|
# Check if this is a translatable string
|
||||||
if ":Nothing" in jaString:
|
if (
|
||||||
# Separate into list
|
not re.search(r"\.[\w]+$", jaString)
|
||||||
list122 = jaString.split("\n\n")
|
and jaString != ""
|
||||||
|
and "_" not in jaString
|
||||||
|
and '",' not in jaString
|
||||||
|
and "/" not in jaString
|
||||||
|
and re.search(LANGREGEX, jaString)
|
||||||
|
):
|
||||||
|
# 1st Pass (Save Text to List)
|
||||||
|
if not setData:
|
||||||
|
list122.append(jaString)
|
||||||
|
|
||||||
# Remove Textwrap
|
# 2nd Pass (Set Text)
|
||||||
# for j in range(len(list122)):
|
else:
|
||||||
# list122[j] = list122[j].replace("\n", " ")
|
if len(list122) > 0:
|
||||||
|
# Grab Translated String
|
||||||
|
translatedText = list122[0]
|
||||||
|
|
||||||
# Translate
|
# Textwrap
|
||||||
response = translateAI(
|
if FIXTEXTWRAP is True:
|
||||||
list122,
|
translatedText = dazedwrap.wrapText(translatedText, width=WIDTH)
|
||||||
f"Reply with the {LANGUAGE} translation of the text",
|
|
||||||
True,
|
|
||||||
)
|
|
||||||
list122TL = response[0]
|
|
||||||
totalTokens[0] += response[1][0]
|
|
||||||
totalTokens[1] += response[1][1]
|
|
||||||
|
|
||||||
# Validate and Set Data
|
# Set Data
|
||||||
if len(list122) == len(list122TL):
|
codeList[i]["stringArgs"][0] = codeList[i]["stringArgs"][0].replace(originalString, translatedText)
|
||||||
# Adjust Speaker and Add Textwrap
|
|
||||||
for j in range(len(list122TL)):
|
|
||||||
list122TL[j] = dazedwrap.wrapText(list122TL[j], WIDTH)
|
|
||||||
list122TL[j] = re.sub(r"^\[?(.+?)\]?:", r"\1:", list122TL[j])
|
|
||||||
list122TL[j] = list122TL[j].replace(":", ":\n")
|
|
||||||
list122TL[j] = list122TL[j].replace(":\n ", ":\n")
|
|
||||||
|
|
||||||
# Join back into single string
|
# Pop Item
|
||||||
list122TL = "\n\n".join(list122TL)
|
list122.pop(0)
|
||||||
|
|
||||||
# Set String
|
|
||||||
codeList[i]["stringArgs"][0] = list122TL
|
|
||||||
|
|
||||||
# Translate Other Strings [Specific Files Only]
|
|
||||||
else:
|
|
||||||
if (
|
|
||||||
not re.search(r"\.[\w]+$", jaString)
|
|
||||||
and 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 = translateAI(
|
|
||||||
jaString,
|
|
||||||
f"Maintain any newlines and Reply with the {LANGUAGE} translation of the text",
|
|
||||||
True,
|
|
||||||
)
|
|
||||||
translatedText = response[0]
|
|
||||||
totalTokens[0] += response[1][0]
|
|
||||||
totalTokens[1] += response[1][1]
|
|
||||||
|
|
||||||
# Textwrap
|
|
||||||
# translatedText = dazedwrap.wrapText(translatedText, 30)
|
|
||||||
|
|
||||||
# Set String
|
|
||||||
codeList[i]["stringArgs"][0] = codeList[i]["stringArgs"][0].replace(originalString, translatedText)
|
|
||||||
|
|
||||||
### Event Code: 150 Picture String
|
### Event Code: 150 Picture String
|
||||||
if codeList[i]["code"] == 150 and CODE150 == True:
|
if codeList[i]["code"] == 150 and CODE150 == True:
|
||||||
|
|
@ -716,6 +687,7 @@ def searchCodes(events, pbar, jobList, filename):
|
||||||
list150TL = []
|
list150TL = []
|
||||||
list250TL = []
|
list250TL = []
|
||||||
list300TL = []
|
list300TL = []
|
||||||
|
list122TL = []
|
||||||
setData = False
|
setData = False
|
||||||
|
|
||||||
# String List
|
# String List
|
||||||
|
|
@ -803,10 +775,25 @@ def searchCodes(events, pbar, jobList, filename):
|
||||||
list150 = list150TL
|
list150 = list150TL
|
||||||
setData = True
|
setData = True
|
||||||
|
|
||||||
|
# 122 List
|
||||||
|
if len(list122) > 0:
|
||||||
|
pbar.total = len(list122)
|
||||||
|
pbar.refresh()
|
||||||
|
response = translateAI(list122, textHistory, True)
|
||||||
|
list122TL = response[0]
|
||||||
|
totalTokens[0] += response[1][0]
|
||||||
|
totalTokens[1] += response[1][1]
|
||||||
|
if len(list122TL) != len(list122):
|
||||||
|
with LOCK:
|
||||||
|
if filename not in MISMATCH:
|
||||||
|
MISMATCH.append(filename)
|
||||||
|
else:
|
||||||
|
setData = True
|
||||||
|
|
||||||
# Update jobList before recursive call
|
# Update jobList before recursive call
|
||||||
if setData == True:
|
if setData == True:
|
||||||
stringList = []
|
stringList = []
|
||||||
jobList = [stringListTL, list210TL, list300TL, list150TL, list250TL] # Add list150TL
|
jobList = [stringListTL, list210TL, list300TL, list150TL, list250TL, list122TL] # Add list122TL
|
||||||
searchCodes(events, pbar, jobList, filename)
|
searchCodes(events, pbar, jobList, filename)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ Here are some vocabulary and terms so that you know the proper spelling and tran
|
||||||
鋼鉄の意志 (Iron Will)
|
鋼鉄の意志 (Iron Will)
|
||||||
スティーリア=ブリュンヒルデ (Stilia Brynhildr) - Female
|
スティーリア=ブリュンヒルデ (Stilia Brynhildr) - Female
|
||||||
|
|
||||||
|
梅園陽芽香 (Himeka Umezono) - Female
|
||||||
|
東十字優蕾 (Yura Azamajuji) - Female
|
||||||
|
|
||||||
# Lewd Terms
|
# Lewd Terms
|
||||||
マンコ (pussy)
|
マンコ (pussy)
|
||||||
おまんこ (vagina)
|
おまんこ (vagina)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue