Spacing issues

This commit is contained in:
Dazed 2023-11-07 12:26:27 -06:00
parent 02c3ec1a89
commit f93ce41bd8
8 changed files with 38 additions and 37 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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