import os, polib FROM = 'ceibal-fr' TO = 'ceibal' po_from = polib.pofile(os.path.join('tmp', '%s.po' % FROM)) po_to = polib.pofile(os.path.join('tmp', '%s.po' % TO)) po_out = polib.POFile() po_out.metadata = { 'Project-Id-Version': 'PACKAGE VERSION', 'Report-Msgid-Bugs-To': '', 'POT-Creation-Date': '2012-04-14 14:55+0200', 'PO-Revision-Date': '2012-04-14 15:10+0200', 'Last-Translator': 'florent ', 'Language-Team': 'LANGUAGE ', 'Language': 'fr', 'MIME-Version': '1.0', 'Content-Type': 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding': '8bit', 'X-Generator': 'Pootle 2.2.0-alpha1a', 'X-POOTLE-MTIME': '1334409010.284015', } for e_to in po_to: for e_from in po_from: if e_to.msgid == e_from.msgid: e_to.msgstr = e_from.msgstr break po_out.append(e_to) po_out.save(os.path.join('tmp', '%s.po' % TO))