| 1 | # -*- coding: utf8 -*- |
|---|
| 2 | |
|---|
| 3 | from itools.gettext import MOFile |
|---|
| 4 | |
|---|
| 5 | def escape(s): |
|---|
| 6 | return s.replace("\\","\\\\") # test! |
|---|
| 7 | |
|---|
| 8 | lng = open("C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\en.lng") |
|---|
| 9 | |
|---|
| 10 | # convertir: msgfmt es.po -o es.mo |
|---|
| 11 | mo = MOFile('C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\es.mo') |
|---|
| 12 | f = open("C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\es.lng","wb") |
|---|
| 13 | |
|---|
| 14 | for line in lng: |
|---|
| 15 | #import pdb; pdb.set_trace() |
|---|
| 16 | msg = line.split("=") |
|---|
| 17 | if len(msg)==2: |
|---|
| 18 | name = msg[0] |
|---|
| 19 | original = escape(msg[1]).encode("utf8").strip() |
|---|
| 20 | translation = mo.gettext(original).replace("\n","\\n") |
|---|
| 21 | f.write("%s=%s\n" % (name, translation.encode("latin1"))) |
|---|
| 22 | |
|---|
| 23 | f.close() |
|---|