From e59ecf694ad2d17673f44186861885561a3a0a0d Mon Sep 17 00:00:00 2001 From: Gmanon Date: Tue, 13 Dec 2022 02:18:04 -0300 Subject: [PATCH] Aea --- .gitignore | 3 +- Translation merger/Translation merger.py | 47 ++++++++++--------- .../files_new/place your files here | 0 .../files_old/place your files here | 0 .../files_out/this is where files come out | 0 5 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 Translation merger/files_new/place your files here delete mode 100644 Translation merger/files_old/place your files here delete mode 100644 Translation merger/files_out/this is where files come out diff --git a/.gitignore b/.gitignore index ac308d8..9a38bba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.rpy -*.rpyc \ No newline at end of file +*.rpyc +*.bak \ No newline at end of file diff --git a/Translation merger/Translation merger.py b/Translation merger/Translation merger.py index 48d60c6..749cc51 100644 --- a/Translation merger/Translation merger.py +++ b/Translation merger/Translation merger.py @@ -1,11 +1,15 @@ -############################################################################################################################## -# This script simply places the strings from files_old into files_new. This is useful if for some reason the labels in the # -# script thanged and you needed to regenerate the translations, or if you already translated the game without using the # -# translation system. # -# # -# Make sure that both files have the same ammounts of lines. Then, simply place the old files into files_old # -# And the new files into files_new. # -############################################################################################################################## +############################################################################################################################ +# This script simply places the strings from files_old into files_new. This is useful if for some reason the labels in the # +# script changed and you needed to regenerate the translations, or if you already translated the game without using the # +# built-in translation system. # +# # +# Make sure that both files have the same ammount of lines. Then, simply place the old files into files_old # +# And the new files into files_new. # +############################################################################################################################ + +#### +# This shit sucks. But it works (As long as you didn't add any extra lines to the translation file) +#### from os import listdir @@ -13,34 +17,33 @@ cont = 0 nextOne = False next_One = False OUT = "out" -FOLDERS = ["old","new"] -for file in listdir(f"files_{FOLDERS[0]}"): +for file in listdir(f"files_old"): if file.endswith(".rpy"): - with open(f"files_{FOLDERS[0]}/{file}",'r', encoding="utf8") as f: + with open(f"files_old/{file}",'r', encoding="utf8") as f: linesOne = f.readlines() - with open(f"files_{FOLDERS[1]}/{file}",'r', encoding="utf8") as f2: + with open(f"files_old/{file}",'r', encoding="utf8") as f2: linesTwo = f2.readlines() if len(linesOne) == len(linesTwo): - with open(f"files_{OUT}/{file}",'w', encoding="utf8") as fp: + with open(f"files_out/{file}",'w', encoding="utf8") as fp: for number,line in enumerate(linesOne): - if line.strip().startswith("#") and line != 0: + if nextOne: + fp.write(linesOne[number]) + nextOne = False + elif next_One and number % 2 == 0: + fp.write(linesOne[number]) + next_One = False + cont = 0 + elif line.strip().startswith("#") and number != 0: next_One = True cont += 1 fp.write(linesTwo[number]) elif line.strip().startswith("old"): nextOne = True fp.write(linesTwo[number]) - elif nextOne: - fp.write(linesOne[number]) - nextOne = False - elif next_One and cont == 2: - fp.write(linesOne[number]) - next_One = False - cont = 0 else: fp.write(linesTwo[number]) else: - print(f"{file}, couldn't be proccesed. There's a discrepancy in the lines. old: {len(linesOne)} - new: {len(linesTwo)}") + print(f"ERROR processing {file}. There's a discrepancy in the lines. old: {len(linesOne)} - new: {len(linesTwo)}\n\n") continue diff --git a/Translation merger/files_new/place your files here b/Translation merger/files_new/place your files here deleted file mode 100644 index e69de29..0000000 diff --git a/Translation merger/files_old/place your files here b/Translation merger/files_old/place your files here deleted file mode 100644 index e69de29..0000000 diff --git a/Translation merger/files_out/this is where files come out b/Translation merger/files_out/this is where files come out deleted file mode 100644 index e69de29..0000000