import os
#LANGUAGE
filename = 'language_DWARF.txt'
files = [filename]
totdat = [[]]*len(files)
for i in range(len(files)):
f = open(files[i],encoding='cp437')
dat = []
for row in f:
dat.append(row)
totdat[i] = dat
f.close()
ddtot = [[]]*len(totdat)
for j in range(len(totdat)):
d = []
for i in range(len(totdat[j])):
if totdat[j][i].count('[TRANSLATION:') >= 1:
y = totdat[j][i].partition('[TRANSLATION:')[2].partition(']')[0]
d.append([y,i])
dd = []
if len(d) >= 1:
for i in range(len(d)-1):
dd.append([d[i][0], d[i][1], d[i+1][1]])
dd.append([d[-1][0], d[-1][1], len(totdat[j])])
ddtot[j] = dd
wf = open(filename, 'w',encoding='cp437')
words = totdat[0][:ddtot[0][0][1]-1]
for i in range(len(ddtot)):
if len(ddtot[i]) > 0:
vals = []
for j in range(len(ddtot[i])):
x = ddtot[i][j][1]
y = ddtot[i][j][2]
z = len(''.join(totdat[i][x+1:y]).split('['))
vals = []
for k in range(z-1):
vals.append(''.join(totdat[i][x+1:y]).split('[')[k+1].split(']')[0].split(':')[1])
order = sorted(range(len(vals)), key=vals.__getitem__)
for k in order:
words.append(totdat[i][x+1+k])
for i in range(len(words)):
wf.write(words[i])
This is python code that alphabetically organizes language files. Works on my system with vanilla languages. It *should* handle multiple [TRANSLATION] in a single file, but I haven't tested it with that.