| 1 | # -*- coding: utf8 -*- |
|---|
| 2 | |
|---|
| 3 | import BeautifulSoup |
|---|
| 4 | |
|---|
| 5 | def escape(s): |
|---|
| 6 | return s.replace("\\","\\\\") # test! |
|---|
| 7 | |
|---|
| 8 | soup = BeautifulSoup.BeautifulSoup(open("es.xml")) |
|---|
| 9 | |
|---|
| 10 | f = open("es.po","wb") |
|---|
| 11 | |
|---|
| 12 | for 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 | |
|---|
| 20 | f.close() |
|---|
| 21 | |
|---|