Add script to sync System.ocg/Language*.txt files

qteditor
Sven Eberhardt 2016-08-04 22:19:39 -04:00
parent 1fd12024c7
commit 395cca18e1
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#!/usr/bin/python
# Add missing entries existing in one Language** file but not in the other
# Also sort entries by key
import os
import glob
language_files = glob.glob('../planet/System.ocg/Language*.txt')
data = [open(fn).read().splitlines() for fn in language_files]
n = len(data)
all_entries = {}
for i,d in enumerate(data):
for l in d:
k,v = l.split('=', 1)
if not k in all_entries:
all_entries[k] = ['MISSING'] * n
all_entries[k][i] = v
fids = [open(fn, 'wt') for fn in language_files]
for k,v in sorted(all_entries.iteritems()):
for i,fid in enumerate(fids):
fid.write('%s=%s\n' % (k, v[i]))
for fid in fids:
fid.close()