# -*- coding: utf-8 -*- # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. # convert german 'de.po' to 'en.po' lines = [] with open('de.po', 'rt') as fhdl: lines = fhdl.readlines() groups = [] group = {} for line in lines: if len(line.strip()) == 0: if len(group) > 0: groups.append(group) group = {} for x in ['msgctxt', 'msgid', 'msgstr']: if line.startswith(x): group[x] = line[len(x):].strip() break used_ids = [] with open('en.po', 'wt') as fhdl: fhdl.write("""# msgid "" msgstr "Content-Type: text/plain; charset=utf-8\\n" """) for line in groups: if line['msgid'].strip() == '""': continue if line['msgctxt'] in used_ids: raise ValueError('duplicate id: %s' % line['msgctxt']) fhdl.write('msgctxt %s\nmsgid %s\nmsgstr %s\n\n' % ( line['msgctxt'], line['msgid'], line['msgid'], ))