Some updates to the modules
This commit is contained in:
parent
3a1a4fd3c0
commit
e16cace75e
3 changed files with 159 additions and 50 deletions
|
|
@ -29,7 +29,7 @@ MAXHISTORY = 10
|
|||
ESTIMATE = ''
|
||||
TOKENS = [0, 0]
|
||||
NAMESLIST = []
|
||||
FIRSTLINESPEAKERS = False # If 1st line of dialogue is a speaker, set to True
|
||||
FIRSTLINESPEAKERS = True # If 1st line of dialogue is a speaker, set to True
|
||||
NAMES = False # Output a list of all the character names found
|
||||
BRFLAG = False # If the game uses <br> instead
|
||||
FIXTEXTWRAP = True # Overwrites textwrap
|
||||
|
|
@ -79,7 +79,7 @@ CODE356 = False
|
|||
CODE320 = False
|
||||
CODE324 = False
|
||||
CODE111 = False
|
||||
CODE108 = True
|
||||
CODE108 = False
|
||||
|
||||
def handleMVMZ(filename, estimate):
|
||||
global ESTIMATE, TOKENS
|
||||
|
|
@ -229,7 +229,11 @@ def parseMap(data, filename):
|
|||
if event is not None:
|
||||
# This translates ID of events. (May break the game)
|
||||
if '<namePop:' in event['note']:
|
||||
response = translateNoteOmitSpace(event, r'<namePop:(.*?)\s?>.+')
|
||||
response = translateNoteOmitSpace(event, r'<namePop:(.*?)\s?>.*')
|
||||
totalTokens[0] += response[0]
|
||||
totalTokens[1] += response[1]
|
||||
if '<LB:' in event['note']:
|
||||
response = translateNoteOmitSpace(event, r'<LB:(.*?)\s?>.*')
|
||||
totalTokens[0] += response[0]
|
||||
totalTokens[1] += response[1]
|
||||
|
||||
|
|
@ -1126,6 +1130,52 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
translatedText = textwrap.fill(translatedText, width=WIDTH)
|
||||
codeList[i]['parameters'][3][argVar] = translatedText
|
||||
pbar.update(1)
|
||||
|
||||
if 'TorigoyaMZ_NotifyMessage' in headerString:
|
||||
argVar = 'message'
|
||||
### Message Text First
|
||||
if argVar in codeList[i]['parameters'][3]:
|
||||
jaString = codeList[i]['parameters'][3][argVar]
|
||||
|
||||
# If there isn't any Japanese in the text just skip
|
||||
if not re.search(r'[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+', jaString):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Remove any textwrap & TL
|
||||
jaString = re.sub(r'\n', ' ', jaString)
|
||||
response = translateGPT(jaString, '', False)
|
||||
translatedText = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
|
||||
# Textwrap & Set
|
||||
translatedText = textwrap.fill(translatedText, width=WIDTH)
|
||||
codeList[i]['parameters'][3][argVar] = translatedText
|
||||
pbar.update(1)
|
||||
|
||||
if '_TMLogWindowMZ' in headerString:
|
||||
argVar = 'text'
|
||||
### Message Text First
|
||||
if argVar in codeList[i]['parameters'][3]:
|
||||
jaString = codeList[i]['parameters'][3][argVar]
|
||||
|
||||
# If there isn't any Japanese in the text just skip
|
||||
# if not re.search(r'[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+', jaString):
|
||||
# i += 1
|
||||
# continue
|
||||
|
||||
# Remove any textwrap & TL
|
||||
jaString = re.sub(r'\n', ' ', jaString)
|
||||
response = translateGPT(jaString, '', False)
|
||||
translatedText = response[0]
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
|
||||
# Textwrap & Set
|
||||
translatedText = textwrap.fill(translatedText, width=WIDTH)
|
||||
codeList[i]['parameters'][3][argVar] = translatedText
|
||||
pbar.update(1)
|
||||
|
||||
## Event Code: 657 [Picture Text] [Optional]
|
||||
if 'code' in codeList[i] and codeList[i]['code'] == 657 and CODE657 is True:
|
||||
|
|
@ -2051,8 +2101,7 @@ def batchList(input_list, batch_size):
|
|||
|
||||
def createContext(fullPromptFlag, subbedT):
|
||||
characters = 'Game Characters:\n\
|
||||
ティアナ (Tiana) - Female\n\
|
||||
キャサリン (Catherine) - Female\n\
|
||||
カエデ (Kaede) - Female\n\
|
||||
'
|
||||
|
||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ def translatePlugin(data, pbar, filename, translatedList):
|
|||
TODO TL all of the above in one call instead of multiple
|
||||
"""
|
||||
# Lines
|
||||
matchList = re.findall(r'.*?[^[]"(.*)"', data[i])
|
||||
matchList = re.findall(r'\\"SpotName[\\]+":[\\]+"(.*?)[\\]+"', data[i])
|
||||
if len(matchList) > 0:
|
||||
for match in matchList:
|
||||
# Save Original String
|
||||
|
|
@ -249,7 +249,7 @@ def getSpeaker(speaker, pbar, filename):
|
|||
case _:
|
||||
# Store Speaker
|
||||
if speaker not in str(NAMESLIST):
|
||||
response = translateGPT(speaker, 'Reply with only the '+ LANGUAGE +' translation of the NPC name.', False, pbar, filename)
|
||||
response = translateGPT(speaker, 'Reply with only the '+ LANGUAGE +' translation of the Location name.', False, pbar, filename)
|
||||
response[0] = response[0].replace("'S", "'s")
|
||||
speakerList = [speaker, response[0]]
|
||||
NAMESLIST.append(speakerList)
|
||||
|
|
|
|||
146
modules/wolf.py
146
modules/wolf.py
|
|
@ -539,6 +539,7 @@ def searchDB(events, pbar, jobList, filename):
|
|||
totalTokens = [0, 0]
|
||||
initialJAString = ''
|
||||
tableList = events
|
||||
font = '\\f[18]'
|
||||
global LOCK
|
||||
global NAMESLIST
|
||||
global MISMATCH
|
||||
|
|
@ -674,27 +675,50 @@ def searchDB(events, pbar, jobList, filename):
|
|||
scenarioList[2].pop(0)
|
||||
|
||||
# Grab Items
|
||||
if table['name'] == '道具' and ITEMFLAG == True:
|
||||
if table['name'] == 'アイテム' and ITEMFLAG == True:
|
||||
for item in table['data']:
|
||||
dataList = item['data']
|
||||
|
||||
# Parse
|
||||
if '名前' in dataList[0].get('name') and dataList[0].get('value') != '':
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
itemList[0].append(dataList[0].get('value'))
|
||||
itemList[1].append(dataList[20].get('value').replace('\n', ' '))
|
||||
itemList[2].append(dataList[21].get('value').replace('\n', ' '))
|
||||
for j in range(len(dataList)):
|
||||
# Name
|
||||
if 'アイテム名' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
itemList[0].append(dataList[0].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
dataList[0].update({'value': itemList[0][0]})
|
||||
itemList[0].pop(0)
|
||||
dataList[20].update({'value': itemList[1][0]})
|
||||
itemList[1].pop(0)
|
||||
itemList[2][0] = textwrap.fill(itemList[2][0], LISTWIDTH)
|
||||
dataList[21].update({'value': itemList[2][0]})
|
||||
itemList[2].pop(0)
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[j].get('value') != '':
|
||||
dataList[j].update({'value': itemList[0][0]})
|
||||
itemList[0].pop(0)
|
||||
|
||||
# Description
|
||||
if '説明文' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
# Remove Textwrap
|
||||
jaString = dataList[j].get('value')
|
||||
jaString = jaString.replace('\n', ' ')
|
||||
jaString = jaString.replace('\r', '')
|
||||
jaString = re.sub(r'[\\]+f\[\d+\]', '', jaString)
|
||||
|
||||
# Append Data
|
||||
itemList[1].append(jaString)
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[j].get('value') != '':
|
||||
# Textwrap
|
||||
translateText = itemList[1][0]
|
||||
translateText = textwrap.fill(translateText, LISTWIDTH)
|
||||
translateText = font + translateText
|
||||
|
||||
# Set Data
|
||||
dataList[j].update({'value': translateText})
|
||||
itemList[1].pop(0)
|
||||
|
||||
# Grab Armors
|
||||
if table['name'] == '防具' and ARMORFLAG == True:
|
||||
|
|
@ -720,32 +744,50 @@ def searchDB(events, pbar, jobList, filename):
|
|||
armorList[1].pop(0)
|
||||
|
||||
# Grab Other
|
||||
if table['name'] == 'ダンジョン敵' and OTHERFLAG == True:
|
||||
if table['name'] == '技能' and OTHERFLAG == True:
|
||||
for other in table['data']:
|
||||
dataList = other['data']
|
||||
|
||||
# Parse
|
||||
if '名前' in dataList[0].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[0].get('value') != '':
|
||||
otherList[0].append(dataList[0].get('value'))
|
||||
# if dataList[1].get('value') != '':
|
||||
# otherList[1].append('Taro' + dataList[1].get('value'))
|
||||
# if dataList[2].get('value') != '':
|
||||
# otherList[2].append('Taro' + dataList[2].get('value'))
|
||||
for j in range(len(dataList)):
|
||||
# Name
|
||||
if '技能の名前' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
otherList[0].append(dataList[0].get('value'))
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[0].get('value') != '':
|
||||
dataList[0].update({'value': otherList[0][0]})
|
||||
otherList[0].pop(0)
|
||||
# if dataList[1].get('value') != '':
|
||||
# dataList[1].update({'value': otherList[1][0].replace('Taro', '')})
|
||||
# otherList[1].pop(0)
|
||||
# if dataList[2].get('value') != '':
|
||||
# dataList[2].update({'value': otherList[2][0].replace('Taro', '')})
|
||||
# otherList[2].pop(0)
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[j].get('value') != '':
|
||||
dataList[j].update({'value': otherList[0][0]})
|
||||
otherList[0].pop(0)
|
||||
|
||||
# Description
|
||||
if '説明' in dataList[j].get('name'):
|
||||
# Pass 1 (Grab Data)
|
||||
if setData == False:
|
||||
if dataList[j].get('value') != '':
|
||||
# Remove Textwrap & Font
|
||||
jaString = dataList[j].get('value')
|
||||
jaString = jaString.replace('\n', ' ')
|
||||
jaString = jaString.replace('\r', '')
|
||||
jaString = re.sub(r'[\\]+f\[\d+\]', '', jaString)
|
||||
|
||||
# Append Data
|
||||
otherList[1].append(jaString)
|
||||
|
||||
# Pass 2 (Set Data)
|
||||
else:
|
||||
if dataList[j].get('value') != '':
|
||||
# Add Textwrap & Font
|
||||
translateText = otherList[1][0]
|
||||
translateText = textwrap.fill(translateText, LISTWIDTH)
|
||||
translateText = font + translateText
|
||||
|
||||
# Set Data
|
||||
dataList[j].update({'value': translateText})
|
||||
otherList[1].pop(0)
|
||||
|
||||
# Grab Collection
|
||||
if table['name'] == '採取' and COLLECTIONFLAG == True:
|
||||
|
|
@ -1110,11 +1152,23 @@ def batchList(input_list, batch_size):
|
|||
|
||||
def createContext(fullPromptFlag, subbedT):
|
||||
characters = 'Game Characters:\n\
|
||||
リリア (Lilia) - Female\n\
|
||||
シェリル (Sheryl) - Female\n\
|
||||
チロ (Chiro) - Female\n\
|
||||
メルキュール (Mercury) - Female\n\
|
||||
のじゃっち (Nojachi) - Female\n\
|
||||
セシリア (Cecilia) - Female\
|
||||
椎那天 (Ten Shiina) - Female\
|
||||
大高あまね (Amane Otaka) - Female\
|
||||
メアリ (Mary) - Female\
|
||||
ルナマリア (Lunamaria) - Female\
|
||||
柚木朱莉 (Akari Yuzuki) - Female\
|
||||
エリス (Elise) - Female\
|
||||
野上菜月 (Natsuki Nogami) - Female\
|
||||
マイナ (Maina) - Female\
|
||||
沢野ぽぷら (Popura Sawano) - Female\
|
||||
シャーリー (Shirley) - Female\
|
||||
餅よもぎ (Yomogi Mochi) - Female\
|
||||
要人アイリス (VIP Iris) - Female\
|
||||
佐藤みるく (Miruku Sato) - Female\
|
||||
少女スゥ (Girl Suu) - Female\
|
||||
山田じぇみ子 (Jemiko Yamada) - Female\
|
||||
大山チロル (Tirol Oyama) - Female\
|
||||
'
|
||||
|
||||
system = PROMPT + VOCAB if fullPromptFlag else \
|
||||
|
|
@ -1164,7 +1218,13 @@ def cleanTranslatedText(translatedText, varResponse):
|
|||
'〜': '~',
|
||||
'ッ': '',
|
||||
'。': '.',
|
||||
'Placeholder Text': ''
|
||||
'< ': '<',
|
||||
'</ ': '</',
|
||||
' >': '>',
|
||||
'「': '\"',
|
||||
' 」': '\"',
|
||||
'- ': '-',
|
||||
'Placeholder Text': '',
|
||||
# Add more replacements as needed
|
||||
}
|
||||
for target, replacement in placeholders.items():
|
||||
|
|
|
|||
Loading…
Reference in a new issue