Skip to content

Commit

Permalink
always keep the header of the language file
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll committed Oct 28, 2023
1 parent 9ad78b5 commit 71f9d16
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions updatelang.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@ def getelement(haystack, needle):
except KeyError:
continue

def updatelang(base, update, lang_file):
newlang = []

found_alias = False

for i, line in enumerate(base):
def getaliasline(array):
for i, line in enumerate(array):
if line["type"] == "single" and line["identifier"] == "__alias":
found_alias = True
return i

if not found_alias and not line["type"] == "code":
if update[i]["content"] == "":
newlang.append("\n")
else:
newlang.append("-- " + update[i]["content"] + "\n")
def updatelang(base, update, lang_file):
newlang = []

continue
# first: copy header from old file
for i in range(0, getaliasline(update)):
line = update[i]

if line["type"] == "comment" or line["type"] == "empty":
if line["content"] != "":
Expand All @@ -32,12 +27,16 @@ def updatelang(base, update, lang_file):
continue

if line["type"] == "code":
old_code = getelement(update, "local")
newlang.append(line["content"] + "\n")

if not old_code:
newlang.append("ERROR: LANGUAGE LINE MISSING\n")
for i in range(getaliasline(base), len(base)):
line = base[i]

if line["type"] == "comment" or line["type"] == "empty":
if line["content"] != "":
newlang.append("-- " + line["content"] + "\n")
else:
newlang.append(old_code["content"] + "\n")
newlang.append("\n")

continue

Expand Down

0 comments on commit 71f9d16

Please sign in to comment.