www: fix links to the new Redmine
[trojita.git] / l10n-fix-old-lconvert.py
blob586b75883cb3b4169bd3cb0fbf8e35fac804de56
1 import sys
3 ts_context_prefix = "#. ts-context "
5 context = None
6 output = []
7 headers_were_sanitized = False
9 for line in sys.stdin.readlines():
10 if line.endswith("\n"):
11 line = line[:-1]
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)
17 context = None
18 output.append(line)
19 elif line == "#, fuzzy":
20 pass
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
28 # works.
29 # Oh I hate this stuff.
30 headers_were_sanitized = True
31 output = [
32 'msgid ""',
33 'msgstr ""',
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"'
39 else:
40 output.append(line)
42 print "\n".join(output)