OneClickInstaller: mo2lng.py

File mo2lng.py, 0.7 KB (added by MarianoReingart, 12 years ago)

Script Python para convertir de .MO (Pootle/gettext) a .LNG (Bitrock installer)

Line 
1# -*- coding: utf8 -*-
2
3from itools.gettext import MOFile
4
5def escape(s):
6    return s.replace("\\","\\\\") # test!
7
8lng = open("C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\en.lng")
9
10# convertir: msgfmt es.po -o es.mo
11mo = MOFile('C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\es.mo')
12f = open("C:\Documents and Settings\Mariano\Escritorio\pg\oneclickinstaller\es.lng","wb")
13
14for 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
23f.close()