diff --git a/modules/main.py b/modules/main.py index 9c0d2ee..18659bb 100644 --- a/modules/main.py +++ b/modules/main.py @@ -115,5 +115,5 @@ def main(): def deleteFolderFiles(folderPath): for filename in os.listdir(folderPath): file_path = os.path.join(folderPath, filename) - if file_path.endswith('.json') or file_path.endswith('.yaml'): + if file_path.endswith(('.json', '.yaml', '.ks')): os.remove(file_path) diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 3ae2991..407eb74 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -1054,10 +1054,10 @@ def searchCodes(page, pbar): else: endString = endString.group() if len(textHistory) > 0: - response = translateGPT(jaString, 'Keep your translation as brief as possible. Previous text for context: ' + textHistory[len(textHistory)-1], True) + response = translateGPT(jaString, 'Keep your translation as brief as possible. Previous text for context: ' + textHistory[len(textHistory)-1] + '\n\nReply in the style of a dialogue option.', True) translatedText = response[0] else: - response = translateGPT(jaString, 'Keep your translation as brief as possible.', True) + response = translateGPT(jaString, 'Keep your translation as brief as possible.\n\nReply in the style of a dialogue option.', True) translatedText = response[0] # Remove characters that may break scripts diff --git a/modules/tyrano.py b/modules/tyrano.py index 2b2dc5c..b5d504c 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -136,6 +136,27 @@ def translateTyrano(data, pbar): else: speaker = '' + # Choices + elif 'glink' in data[i]: + matchList = re.findall(r'text=\"(.+?)\"', data[i]) + if len(matchList) != 0: + if len(textHistory) > 0: + response = translateGPT(matchList[0], 'Past Translated Text: ' + textHistory[len(textHistory)-1] + '\n\nReply in the style of a dialogue option.', True) + else: + response = translateGPT(matchList[0], '', False) + translatedText = response[0] + tokens += response[1] + + # Remove characters that may break scripts + charList = ['.', '\"', '\\n'] + for char in charList: + translatedText = translatedText.replace(char, '') + + # Set Data + translatedText = translatedText.replace(' ', ' ') + data[i] = re.sub(r'(text=)\"(.+?)\"', rf'\1{translatedText}', data[i]) + + # Lines elif '[p]' in data[i]: matchList = re.findall(r'(.+?)\[p\]', data[i]) @@ -170,20 +191,34 @@ def translateTyrano(data, pbar): textHistory.append('\"' + translatedText + '\"') # Remove added speaker - translatedText = translatedText.replace(speaker + ': ', '') + translatedText = re.sub(r'^.+:\s?', '', translatedText) # Set Data + translatedText = translatedText.replace('ッ', '') + translatedText = translatedText.replace('っ', '') + translatedText = translatedText.replace('ー', '') translatedText = translatedText.replace('\"', '') # Format Text - matchList = re.findall(r'(.+?[\.\?\!)。・]+)', translatedText) - translatedText = re.sub(r'(.+?[\.\?\!)。・]+)', '', translatedText) + matchList = re.findall(r'(.+?[)\.\?\!)。・]+)', translatedText) + translatedText = re.sub(r'(.+?[)\.\?\!)。・]+)', '', translatedText) + + # Combine Lists + for k in range(len(matchList)): + matchList[k] = matchList[k].strip() + j=0 + while(len(matchList) > j+1): + while len(matchList[j]) < 100 and len(matchList) > j: + matchList[j:j+2] = [' '.join(matchList[j:j+2])] + if len(matchList) == j+1: + break + j+=1 + if len(matchList) > 0: - del data[i] + data[i] = '\d\n' for line in matchList: data.insert(i, line.strip() + '[p]\n') i+=1 - i-=1 # else: # print ('No Matches') if translatedText != '':