[icinga-checkins] icinga.org: icinga-web/master: * Script to duplicate empty translation entries

git at icinga.org git at icinga.org
Wed Dec 14 15:53:05 CET 2011


Module: icinga-web
Branch: master
Commit: b02e523ff1322d32b4456c8fa6f831ca617f4c1f
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=b02e523ff1322d32b4456c8fa6f831ca617f4c1f

Author: Marius Hein <marius.hein at netways.de>
Date:   Wed Dec 14 15:52:14 2011 +0100

* Script to duplicate empty translation entries

---

 bin/loc-duplicate-translation.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/bin/loc-duplicate-translation.py b/bin/loc-duplicate-translation.py
new file mode 100755
index 0000000..d435b31
--- /dev/null
+++ b/bin/loc-duplicate-translation.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+from optparse import OptionParser
+import sys
+import re
+import fileinput
+
+script = sys.argv[0]
+
+parser = OptionParser()
+
+parser.add_option("-f", "--file", dest="filename",
+                  help="Filename to work on")
+
+(options, args) = parser.parse_args()
+
+if not options.filename:
+	print("Filename is required: " + script + " -f <filename>")
+
+re_msgid = re.compile(r"^msgid\s+\"(.+)\"$");
+mo = False
+
+for line in fileinput.input(options.filename, inplace=1):
+	if not mo:
+		mo = re_msgid.match(line)
+	elif mo:
+		if line == "msgstr \"\"\n":
+			line = "msgstr \"" + mo.group(1) + "\"\n"
+		mo = False
+	sys.stdout.write(line)





More information about the icinga-checkins mailing list