PgInstaller: wix2po.py

File wix2po.py, 0.5 KB (added by MarianoReingart, 3 years ago)

Script para convertir los XML (WIX) a PO

Line 
1# -*- coding: utf8 -*-
2
3import BeautifulSoup
4
5def escape(s):
6    return s.replace("\\","\\\\") # test!
7
8soup = BeautifulSoup.BeautifulSoup(open("es.xml"))
9
10f = open("es.po","wb")
11
12for tag in soup.findAll('string'):
13    #import pdb; pdb.set_trace()
14    print "%s=%s" % (tag['original'].encode("latin1"), tag['translation'].encode("latin1"))
15    original = escape(tag['original']).encode("utf8")
16    translation = escape(tag['translation']).encode("utf8")
17    f.write('msgid "%s"\n' % original )
18    f.write('msgstr "%s"\n\n' % translation)
19
20f.close()
21