diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac308d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.rpy +*.rpyc \ No newline at end of file diff --git a/Translation merger/Translation merger.py b/Translation merger/Translation merger.py new file mode 100644 index 0000000..48d60c6 --- /dev/null +++ b/Translation merger/Translation merger.py @@ -0,0 +1,46 @@ +############################################################################################################################## +# 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. # +############################################################################################################################## + +from os import listdir + +cont = 0 +nextOne = False +next_One = False +OUT = "out" +FOLDERS = ["old","new"] + +for file in listdir(f"files_{FOLDERS[0]}"): + if file.endswith(".rpy"): + with open(f"files_{FOLDERS[0]}/{file}",'r', encoding="utf8") as f: + linesOne = f.readlines() + with open(f"files_{FOLDERS[1]}/{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: + for number,line in enumerate(linesOne): + if line.strip().startswith("#") and line != 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)}") + continue diff --git a/Translation merger/files_new/place your files here b/Translation merger/files_new/place your files here new file mode 100644 index 0000000..e69de29 diff --git a/Translation merger/files_old/place your files here b/Translation merger/files_old/place your files here new file mode 100644 index 0000000..e69de29 diff --git a/Translation merger/files_out/this is where files come out b/Translation merger/files_out/this is where files come out new file mode 100644 index 0000000..e69de29