Browse Source

Ensure field order is constant throughout Translations file.

We need to be sure Description-[lang] sorts after Description-md5 for all i18n
languages. So define order for Packages and Description-md5 and add
Description-[lang] at the end.
main
Mark Hindley 2 years ago
parent
commit
74c50da9c1
  1. 8
      amprolla_merge_translations.py

8
amprolla_merge_translations.py

@ -64,10 +64,10 @@ def write_translations(translations, filename):
bz2f = bz2_open(filename, 'w')
for pkg, fields in sorted(translations.items()):
ordered_keys = ['Package']
ordered_keys.extend(sorted((k for k in fields.keys()
if k.startswith('Description-'))))
for key in ordered_keys:
order = ['Package','Description-md5']
for key in sorted((k for k in fields.keys()
if k == 'Package' or k.startswith('Description-')),
key=lambda k: order.index(k) if k in order else len(order)+1):
line = "%s: %s\n" % (key, fields[key])
bz2f.write(line.encode('utf-8'))
bz2f.write(b'\n')

Loading…
Cancel
Save