File: clonk.py

package info (click to toggle)
openclonk 8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 169,520 kB
  • sloc: cpp: 180,479; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 145; sh: 101; javascript: 34
file content (62 lines) | stat: -rw-r--r-- 2,457 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# the description of the format used for the clonk developer docs for xml2po
class clonkXmlMode:
    """Clonks propietary xml format"""
    def getIgnoredTags(self):
        "Returns array of tags to be ignored."
        return ['emlink', 'em', 'strong', 'code']
    def getFinalTags(self):
        "Returns array of tags to be considered 'final'."
        return ['table', 'text', 'desc', 'remark', 'col', 'li', 'funclink', 'ul', 'h', 'dt']
    def getSwallowTags(self):
        "Return array of tags which content is not translated."
        return self._stuff
    def getSpacePreserveTags(self):
        "Returns array of tags in which spaces are to be preserved."
        return ['code']

    _stuff = ['funclink', 'version', 'extversion', 'rtype', 'author', 'date',
        'type', 'code', 'code/i', 'code/b', 'name', 'func/title', 'const/title', 'literal_col']
    def _delete_stuff(self, node, msg):
        #print "looking at " + str(node.name)
        if node and node.children:
            child = node.children
            while child:
                n = child
                child = child.next
                if n.type=='element' and n.name in self._stuff:
                    #print "!"
                    if n.name == 'name' and node.name != 'param':
                        print node + "!" + n
                    #n.unlinkNode()
                    #n.freeNode()
                    n.setContent('')
                else:
                    self._delete_stuff(n, msg)


    def preProcessXml(self, doc, msg):
        """Add additional messages of interest here."""
        return
        #root = doc.getRootElement()
        #self._delete_stuff(root,msg)

    def postProcessXmlTranslation(self, doc, language, translators):
        """Sets a language and translators in "doc" tree.
        
        "translators" is a string consisted of translator credits.
        "language" is a simple string.
        "doc" is a libxml2.xmlDoc instance."""
        root = doc.getRootElement()
        root.setProp('xml:lang', language)

    def getStringForTranslators(self):
        """Returns None or a string to be added to PO files.

        Common example is 'translator-credits'."""
        return None

    def getCommentForTranslators(self):
        """Returns a comment to be added next to string for crediting translators.

        It should explain the format of the string provided by getStringForTranslators()."""
        return None