From 11b3d1eb80b9410e7520ff2841f1a48c343cefc4 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Sun, 4 May 2014 15:25:10 +0200 Subject: [PATCH] Add a script to normalize a .po file --- scripts/normalize_po.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/normalize_po.py diff --git a/scripts/normalize_po.py b/scripts/normalize_po.py new file mode 100644 index 000000000..5206a41c2 --- /dev/null +++ b/scripts/normalize_po.py @@ -0,0 +1,11 @@ +import polib +import sys + +if __name__ == '__main__': + for filename in sys.argv[1:]: + po = polib.pofile(open(filename).read()) + entries = list(sorted(sorted(po, key=lambda x: x.msgctxt or ""), key=lambda x: x.msgid)) + po.clear() + for entry in entries: + po.append(entry) + po.save(filename)