changeset 7957:26971f97105f

Added script to find unused i18n in *.java and *.xml files.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 19 Jun 2014 18:20:39 +0200
parents ed37ba051103
children 632c724fed2d
files artifacts/contrib/find-obsolete-i18n-strings.py
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/contrib/find-obsolete-i18n-strings.py	Thu Jun 19 18:20:39 2014 +0200
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+
+KEY_RE = re.compile(r"^\s*([^\s=]+)\s*=.*$")
+
+def main():
+    content = []
+    for root, dirs, files in os.walk('.'):
+        for f in files:
+            if not (f.endswith(".java") or f.endswith(".xml")):
+                continue
+            p = os.path.join(root, f)
+            with open(p, "rb") as jf:
+                content.append(jf.read())
+
+    content = ''.join(content)
+
+    for arg in sys.argv[1:]:
+        with open(arg, "rb") as prop:
+            for line in prop:
+                m = KEY_RE.match(line)
+                if not m:
+                    continue
+                key = m.group(1)
+                if content.find(key) == -1:
+                    print key
+
+if __name__ == "__main__":
+    main()

http://dive4elements.wald.intevation.org