1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 from translate.storage import base
23 from translate.storage import poheader
24
25 import re
26
27 msgid_comment_re = re.compile("_: (.*?)\n")
28
38
39
40 -class pounit(base.TranslationUnit):
41
42 - def adderror(self, errorname, errortext):
43 """Adds an error message to this unit."""
44 text = u'(pofilter) %s: %s' % (errorname, errortext)
45
46 if text not in self.getnotes(origin='translator'):
47 self.addnote(text, origin="translator")
48
50 """Get all error messages."""
51 notes = self.getnotes(origin="translator").split('\n')
52 errordict = {}
53 for note in notes:
54 if '(pofilter) ' in note:
55 error = note.replace('(pofilter) ', '')
56 errorname, errortext = error.split(': ')
57 errordict[errorname] = errortext
58 return errordict
59
61 """Marks the unit to indicate whether it needs review. Adds an optional explanation as a note."""
62 if needsreview:
63 reviewnote = "(review)"
64 if explanation:
65 reviewnote += " " + explanation
66 self.addnote(reviewnote, origin="translator")
67 else:
68
69 notestring = self.getnotes(origin="translator")
70 notes = notestring.split('\n')
71 newnotes = []
72 for note in notes:
73 if not '(review)' in note:
74 newnotes.append(note)
75 newnotes = '\n'.join(newnotes)
76 self.removenotes()
77 self.addnote(newnotes, origin="translator")
78
81
84
87
88
89 -class pofile(poheader.poheader, base.TranslationStore):
90 Name = _("Gettext PO file")
91 Mimetypes = ["text/x-gettext-catalog", "text/x-gettext-translation", "text/x-po", "text/x-pot"]
92 Extensions = ["po", "pot"]
93