50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
############################################################################################################################
|
|
# 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
|
|
|
|
cont = 0
|
|
nextOne = False
|
|
next_One = False
|
|
OUT = "out"
|
|
|
|
for file in listdir(f"files_old"):
|
|
if file.endswith(".rpy"):
|
|
with open(f"files_old/{file}",'r', encoding="utf8") as f:
|
|
linesOne = f.readlines()
|
|
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:
|
|
for number,line in enumerate(linesOne):
|
|
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])
|
|
else:
|
|
fp.write(linesTwo[number])
|
|
else:
|
|
print(f"ERROR processing {file}. There's a discrepancy in the lines. old: {len(linesOne)} - new: {len(linesTwo)}\n\n")
|
|
continue
|