[rkward-cvs] [rkward] scripts: Pro-actively scan all included files for labels. (Without this, in some cases, labels would not be resolved).

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Sat Jan 31 16:32:46 UTC 2015


Git commit 929455ef6b74b49e7cf86568e28265e0f10d2978 by Thomas Friedrichsmeier.
Committed on 31/01/2015 at 16:29.
Pushed by tfry into branch 'master'.

Pro-actively scan all included files for labels. (Without this, in some cases, labels would not be resolved).

M  +11   -5    scripts/update_plugin_messages.py

http://commits.kde.org/rkward/929455ef6b74b49e7cf86568e28265e0f10d2978

diff --git a/scripts/update_plugin_messages.py b/scripts/update_plugin_messages.py
index 8440893..ce0ee06 100755
--- a/scripts/update_plugin_messages.py
+++ b/scripts/update_plugin_messages.py
@@ -266,6 +266,15 @@ def getElementLabelsRecursive (elem):
       ret.update (getElementLabelsRecursive (ce))
   return ret
 
+def getAllElementLabels (xmldoc, filename):
+  ret = getElementLabelsRecursive (xmldoc)
+  includes = xmldoc.getElementsByTagName ("include")
+  for inc in includes:
+    subfile = os.path.join (os.path.dirname (filename), inc.getAttribute ("file"))
+    subdoc = parseFile (subfile)
+    ret.update (getAllElementLabels (subdoc, subfile))
+  return ret
+
 # It really is sort of lame to have to parse JS and extract i18n-calls, when xgettext could do it. But that would not
 # - allow us to add info on which plugin this belongs to
 # - list the i18n strings from the JS file in sequence with the i18n strings from the XML parts of the same plugin
@@ -455,11 +464,8 @@ def handleSubFile (filename, fetch_ids = False, is_include=False):
     infile["infile"] = filename
     infile["file_prefix"] = xmldoc.documentElement.getAttribute ("base_prefix")
     infile["caption"] = getFileCaption (xmldoc.documentElement, oldinfile["caption"])
-    if (fetch_ids or is_include):
-      if (is_include):
-        infile["id_labels"].update (getElementLabelsRecursive (xmldoc.documentElement).items ())
-      else:
-        infile["id_labels"] = getElementLabelsRecursive (xmldoc.documentElement)
+    if (fetch_ids):
+      infile["id_labels"] = getAllElementLabels (xmldoc.documentElement, filename)
     handleNode (xmldoc.documentElement)
     infile = oldinfile
 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
rkward-cvs mailing list
rkward-cvs at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-cvs


More information about the rkward-tracker mailing list