tools: script to fix Weblate/gettext header wrap format mismatch

parent 258b1491
#!/usr/bin/env python3
import re
import sys
BAD_HEADER_RE = re.compile('msgstr "Project-Id-Version.*\\\\n"')
if len(sys.argv) <= 1:
print('Usage:', sys.argv[0])
for f in sys.argv[1:]:
with open(f) as fp:
data =
m =
if m:
header = re.sub(r'\\n([^"])', r'\\n"\n"\1','msgstr "Project', 'msgstr ""\n"Project'))
out = re.sub(r'(<<<<<<<|>>>>>>>).*\n', '', data.replace(, header))
out = re.sub(r'("POT-Creation-Date: 20.*\\n"\n"PO-).+"PO-', r'\1', out, flags=re.DOTALL)
with open(f, 'w') as fp:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment