I give up on trying to make escaped quotation marks work

This commit is contained in:
GManon 2023-01-22 01:46:09 -03:00
parent a7947efa81
commit a412c30ce2
3 changed files with 7 additions and 8 deletions

View File

@ -54,10 +54,11 @@ for file_name in os.listdir('scripts'):
for line in lines:
# Check if the line is commented out
if not line.strip().startswith('#'):
words = line.split('"')[1::2]
words = line.split('"')[1:-1]
# Replace the English string with the translated string
try:
line = line.replace(words[-1],translations[words[-1]])
words = "".join(words)
line = line.replace(words,translations[words])
except:
pass
# Write the modified line to the output file

View File

@ -14,7 +14,8 @@ pip install colorama
respectively.
It expects a `dialogue.txt` generated from renpy. I personally only include dialogue (that is, no screen text), but it should work regardless if you choose to include it. Including the tags is NECESSARY, otherwise `applier.py` will fail.
It expects a `dialogue.txt` generated from renpy and a translation script from renpy. I personally only include dialogue (that is, no screen text), but it should work regardless if you choose to include it. Including the tags is NECESSARY, otherwise `applier.py` will fail.
Your script files MUST include all the dialogue, that is, you mustn't have "generate empty translation strings" selected when generating the translation scripts.
They are meant to be run in this order:

View File

@ -26,7 +26,7 @@ def translate(string):
for idx, token in enumerate(tokens):
if token[0] == "{" or token[0] == "[":
to_restore.append(token)
# Emojis aren't touched by the translator and retain their position 😎
# Emojis aren't touched by the translator and retain their relative position 😎
tokens[idx] = "🔠"
encoded_string = "".join(tokens)
@ -65,9 +65,6 @@ with open('original.csv', 'r', encoding='utf-8') as input_file, \
# Translate the string
translation = translate(row[0])
#Hope this works for escaping, lol
translation = translation.replace('"',r'\"')
except Exception as e:
print(f'{Fore.RESET}An error occurred: {e}')
@ -87,6 +84,6 @@ with open('original.csv', 'r', encoding='utf-8') as input_file, \
print(f'{Fore.RED}Original: {Fore.RESET}{row[0]} | {Fore.GREEN}Translation: {Fore.RESET}{translation}{" "*10}\n{Fore.CYAN}Estimated time remaining: {str(time_remaining).split(".")[0]} {Fore.YELLOW}({i}/{length})', end="\r")
writer.writerow([row[0].replace('"',r'\"'), translation])
writer.writerow([row[0], translation])
print(f"\n\n{Fore.YELLOW}FINISHED")