From f93ce41bd8dee2ffe97052d7ffa7fe7ff425f90f Mon Sep 17 00:00:00 2001 From: Dazed Date: Tue, 7 Nov 2023 12:26:27 -0600 Subject: [PATCH] Spacing issues --- modules/csv.py | 2 +- modules/json.py | 57 +++++++++++++++++++++-------------------- modules/kansen.py | 2 +- modules/lune.py | 6 ++--- modules/rpgmakerace.py | 2 +- modules/rpgmakermvmz.py | 2 +- modules/txt.py | 2 +- modules/tyrano.py | 2 +- 8 files changed, 38 insertions(+), 37 deletions(-) diff --git a/modules/csv.py b/modules/csv.py index 959ce43..7112ef2 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -276,7 +276,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'<\s?.+?\s?>', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/json.py b/modules/json.py index e1fc72d..1ab33fe 100644 --- a/modules/json.py +++ b/modules/json.py @@ -149,39 +149,40 @@ def translateJSON(data, pbar): speaker = 'None' # Text - if 'text' in item[1]: - if item[1]['text'] != None: - jaString = item[1]['text'] + for text in ['text', 'help1', 'help2', 'help3', 'like', 'message']: + if text in item[1]: + if item[1][text] != None: + jaString = item[1][text] - # Remove any textwrap - if FIXTEXTWRAP == True: - jaString = jaString.replace('\n', '') + # Remove any textwrap + if FIXTEXTWRAP == True: + jaString = jaString.replace('\n', ' ') - # Translate - if jaString != '': - response = translateGPT(f'{speaker} | {jaString}', textHistory, True) - tokens[0] += response[1][0] - tokens[1] += response[1][1] - translatedText = response[0] - textHistory.append('\"' + translatedText + '\"') - else: - translatedText = jaString - textHistory.append('\"' + translatedText + '\"') + # Translate + if jaString != '': + response = translateGPT(f'{speaker} | {jaString}', textHistory, True) + tokens[0] += response[1][0] + tokens[1] += response[1][1] + translatedText = response[0] + textHistory.append('\"' + translatedText + '\"') + else: + translatedText = jaString + textHistory.append('\"' + translatedText + '\"') - # Remove added speaker - translatedText = re.sub(r'^.+?\s\|\s?', '', translatedText) + # Remove added speaker + translatedText = re.sub(r'^.+?\s\|\s?', '', translatedText) - # Textwrap - translatedText = textwrap.fill(translatedText, width=WIDTH) + # Textwrap + translatedText = textwrap.fill(translatedText, width=WIDTH) - # Set Data - item[1]['text'] = translatedText + # Set Data + item[1][text] = translatedText - # Keep textHistory list at length maxHistory - if len(textHistory) > maxHistory: - textHistory.pop(0) - currentGroup = [] - pbar.update(1) + # Keep textHistory list at length maxHistory + if len(textHistory) > maxHistory: + textHistory.pop(0) + currentGroup = [] + pbar.update(1) return tokens @@ -244,7 +245,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/kansen.py b/modules/kansen.py index 6492197..464599e 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -420,7 +420,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/lune.py b/modules/lune.py index 2dc6316..f3548c2 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -156,7 +156,7 @@ def translateJSON(data, pbar): # Remove any textwrap if FIXTEXTWRAP == True: - jaString = jaString.replace('\n', '') + jaString = jaString.replace('\n', ' ') # Translate if jaString != '': @@ -182,7 +182,7 @@ def translateJSON(data, pbar): if len(textHistory) > maxHistory: textHistory.pop(0) currentGroup = [] - pbar.update(1) + pbar.update(1) return tokens @@ -245,7 +245,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index d20f0c8..25674a6 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -1709,7 +1709,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 7610d32..daef838 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -1704,7 +1704,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/txt.py b/modules/txt.py index c3cf801..05f58de 100644 --- a/modules/txt.py +++ b/modules/txt.py @@ -263,7 +263,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'<\s?.+?\s?>', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons diff --git a/modules/tyrano.py b/modules/tyrano.py index 88561c2..97b0b41 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -434,7 +434,7 @@ def resubVars(translatedText, allList): matchList = re.findall(r'\[\s?.+?\s?\]', translatedText) if len(matchList) > 0: for match in matchList: - text = match.replace(' ', '') + text = match.strip() translatedText = translatedText.replace(match, text) # Icons