diff --git a/Auto Trans/Applier.py b/Auto Trans/Applier.py index bcb6888..ca0eff4 100644 --- a/Auto Trans/Applier.py +++ b/Auto Trans/Applier.py @@ -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 diff --git a/Auto Trans/README.md b/Auto Trans/README.md index 5dec422..ebff5ef 100644 --- a/Auto Trans/README.md +++ b/Auto Trans/README.md @@ -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: diff --git a/Auto Trans/Translator.py b/Auto Trans/Translator.py index f28480b..ae707b1 100644 --- a/Auto Trans/Translator.py +++ b/Auto Trans/Translator.py @@ -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")