Added translation merger
This commit is contained in:
46
Translation merger/Translation merger.py
Normal file
46
Translation merger/Translation merger.py
Normal file
@ -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
|
0
Translation merger/files_new/place your files here
Normal file
0
Translation merger/files_new/place your files here
Normal file
0
Translation merger/files_old/place your files here
Normal file
0
Translation merger/files_old/place your files here
Normal file
Reference in New Issue
Block a user