diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-03-21 19:47:31 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-03-21 19:47:31 (GMT) |
commit | 41ecc60e682a745e55ab2a2ebb9770c953452ce5 (patch) | |
tree | db6f266de859003035c1c699889a341b52612a7d | |
parent | 6562fc813e411cac2771906407809c2357ae2ac0 (diff) | |
download | swift-contrib-41ecc60e682a745e55ab2a2ebb9770c953452ce5.zip swift-contrib-41ecc60e682a745e55ab2a2ebb9770c953452ce5.tar.bz2 |
Added CheckTranslations script.
-rwxr-xr-x | BuildTools/CheckTranslations.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/BuildTools/CheckTranslations.py b/BuildTools/CheckTranslations.py new file mode 100755 index 0000000..5796bac --- /dev/null +++ b/BuildTools/CheckTranslations.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import os, sys, re, xml.dom.minidom + +def getText(nodelist): + text = "" + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + text += node.data + return text + + +for filename in os.listdir("Swift/Translations") : + m = re.match("swift_(.*)\.ts", filename) + if m : + language = m.group(1) + f = open("Swift/Translations/" + filename, "r") + document = xml.dom.minidom.parse(f) + f.close() + + for message in document.getElementsByTagName("message") : + source = message.getElementsByTagName("source")[0] + sourceText = getText(source.childNodes) + sourcePlaceholders = set(re.findall("%\d+%?", sourceText)) + translation = message.getElementsByTagName("translation")[0] + translationText = getText(translation.childNodes) + translationPlaceholders = set(re.findall("%\d+%?", translationText)) + if translationPlaceholders != sourcePlaceholders : + print "[Error] " + filename + ": Placeholder mismatch in translation '" + sourceText + "'" |