From 7f7fb2354f505f0a4b37c1bbe5e26a79c1313d8a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 12 Apr 2007 13:26:06 +0000 Subject: [PATCH] - Added some scripts that might be useful in the future --- src/convertPOtoTS.py | 19 +++++++++++++++++++ src/convertTStoPO.py | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/convertPOtoTS.py create mode 100755 src/convertTStoPO.py diff --git a/src/convertPOtoTS.py b/src/convertPOtoTS.py new file mode 100644 index 000000000..d9b8cd032 --- /dev/null +++ b/src/convertPOtoTS.py @@ -0,0 +1,19 @@ +#!/usr/bin/python + +import os + +LANG_FOLDER = "lang/" +PO_FOLDER = 'po_files' + +if __name__ == '__main__': + po_files = os.listdir(os.path.join(LANG_FOLDER, PO_FOLDER)) + po_files = [x for x in po_files if os.path.splitext(x)[-1] == ".po"] + for file in po_files: + # First clean up the ts file + ts_file = os.path.join(LANG_FOLDER, os.path.splitext(file)[0]+'.ts') + po_file = os.path.join(LANG_FOLDER, PO_FOLDER, file) + if os.path.exists(ts_file): + os.remove(ts_file) + # Convert to PO + print "Converting %s..." % (po_file,) + os.system("po2ts %s -o %s" % (po_file, ts_file)) diff --git a/src/convertTStoPO.py b/src/convertTStoPO.py new file mode 100755 index 000000000..4df1af961 --- /dev/null +++ b/src/convertTStoPO.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import os + +LANG_FOLDER = 'lang/' +PO_FOLDER = 'po_files' + +if __name__ == '__main__': + ts_files = os.listdir(LANG_FOLDER) + ts_files = [x for x in ts_files if os.path.splitext(x)[-1] == ".ts"] + for file in ts_files: + # First clean up the po file + po_file = os.path.join(LANG_FOLDER, PO_FOLDER, os.path.splitext(file)[0]+'.po') + ts_file = os.path.join(LANG_FOLDER, file) + if os.path.exists(po_file): + os.remove(po_file) + # create po folder if it doesn't exist + if not os.path.exists(os.path.join(LANG_FOLDER, PO_FOLDER)): + os.mkdir(os.path.join(LANG_FOLDER, PO_FOLDER)) + # Convert to PO + print "Converting %s..." % (ts_file,) + os.system("ts2po %s -o %s" % (ts_file, po_file)) + # Making an archive + os.system("tar czf %s %s" % (os.path.join(LANG_FOLDER, PO_FOLDER)+'.tar.gz', os.path.join(LANG_FOLDER, PO_FOLDER)))