3 ts_context_prefix
= "#. ts-context "
7 headers_were_sanitized
= False
9 for line
in sys
.stdin
.readlines():
10 if line
.endswith("\n"):
12 if line
.startswith(ts_context_prefix
):
13 context
= line
[len(ts_context_prefix
):]
14 elif line
.startswith("msgid "):
15 if context
is not None:
16 output
.append('msgctxt "%s|"' % context
)
19 elif line
== "#, fuzzy":
21 elif not headers_were_sanitized
and \
22 line
== r
'"X-Virgin-Header: remove this line if you change anything in the header.\n"':
23 # We know that we're on an ancient version of lconvert which produces
24 # stuff which require heavy, heavy sanitization.
25 # The header in particular is all wrong; it misses the crucial
26 # "X-Qt-Contexts" thing without which our sed magic doesn't fix the
27 # contexts at all, so better replace it with somethig which actually
29 # Oh I hate this stuff.
30 headers_were_sanitized
= True
34 r
'"MIME-Version: 1.0\n"',
35 r
'"Content-Type: text/plain; charset=UTF-8\n"',
36 r
'"Content-Transfer-Encoding: 8bit\n"',
37 r
'"X-Qt-Contexts: true\n"'
42 print "\n".join(output
)