| 66 | | if os.path.exists(potfile): |
|---|
| | 72 | print "processing language", lang |
|---|
| | 73 | basedir = os.path.join(localedir, lang, 'LC_MESSAGES') |
|---|
| | 74 | if not os.path.isdir(basedir): |
|---|
| | 75 | os.makedirs(basedir) |
|---|
| | 76 | |
|---|
| | 77 | pofile = os.path.join(basedir, '%s.po' % domain) |
|---|
| | 78 | potfile = os.path.join(basedir, '%s.pot' % domain) |
|---|
| | 79 | |
|---|
| | 80 | if os.path.exists(potfile): |
|---|
| | 81 | os.unlink(potfile) |
|---|
| | 82 | |
|---|
| | 83 | for (dirpath, dirnames, filenames) in os.walk("."): |
|---|
| | 84 | for file in filenames: |
|---|
| | 85 | if file.endswith('.py') or file.endswith('.html'): |
|---|
| | 86 | thefile = file |
|---|
| | 87 | if file.endswith('.html'): |
|---|
| | 88 | src = open(os.path.join(dirpath, file), "rb").read() |
|---|
| | 89 | open(os.path.join(dirpath, '%s.py' % file), "wb").write(templateize(src)) |
|---|
| | 90 | thefile = '%s.py' % file |
|---|
| | 91 | if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) |
|---|
| | 92 | cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % ( |
|---|
| | 93 | os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile)) |
|---|
| | 94 | msgs = os.popen(cmd, 'r').read() |
|---|
| | 95 | if thefile != file: |
|---|
| | 96 | old = '#: '+os.path.join(dirpath, thefile)[2:] |
|---|
| | 97 | new = '#: '+os.path.join(dirpath, file)[2:] |
|---|
| | 98 | msgs = msgs.replace(old, new) |
|---|
| | 99 | if msgs: |
|---|
| | 100 | open(potfile, 'ab').write(msgs) |
|---|
| | 101 | if thefile != file: |
|---|
| | 102 | os.unlink(os.path.join(dirpath, thefile)) |
|---|
| | 103 | |
|---|
| | 104 | msgs = os.popen('msguniq %s' % potfile, 'r').read() |
|---|
| | 105 | open(potfile, 'w').write(msgs) |
|---|
| | 106 | if os.path.exists(pofile): |
|---|
| | 107 | msgs = os.popen('msgmerge %s %s' % (pofile, potfile), 'r').read() |
|---|
| | 108 | open(pofile, 'wb').write(msgs) |
|---|
| 69 | | for (dirpath, dirnames, filenames) in os.walk("."): |
|---|
| 70 | | for file in filenames: |
|---|
| 71 | | if file.endswith('.py') or file.endswith('.html'): |
|---|
| 72 | | thefile = file |
|---|
| 73 | | if file.endswith('.html'): |
|---|
| 74 | | src = open(os.path.join(dirpath, file), "rb").read() |
|---|
| 75 | | open(os.path.join(dirpath, '%s.py' % file), "wb").write(templateize(src)) |
|---|
| 76 | | thefile = '%s.py' % file |
|---|
| 77 | | if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) |
|---|
| 78 | | cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % ( |
|---|
| 79 | | os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile)) |
|---|
| 80 | | msgs = os.popen(cmd, 'r').read() |
|---|
| 81 | | if thefile != file: |
|---|
| 82 | | old = '#: '+os.path.join(dirpath, thefile)[2:] |
|---|
| 83 | | new = '#: '+os.path.join(dirpath, file)[2:] |
|---|
| 84 | | msgs = msgs.replace(old, new) |
|---|
| 85 | | if msgs: |
|---|
| 86 | | open(potfile, 'ab').write(msgs) |
|---|
| 87 | | if thefile != file: |
|---|
| 88 | | os.unlink(os.path.join(dirpath, thefile)) |
|---|
| 89 | | |
|---|
| 90 | | msgs = os.popen('msguniq %s' % potfile, 'r').read() |
|---|
| 91 | | open(potfile, 'w').write(msgs) |
|---|
| 92 | | if os.path.exists(pofile): |
|---|
| 93 | | msgs = os.popen('msgmerge %s %s' % (pofile, potfile), 'r').read() |
|---|
| 94 | | open(pofile, 'wb').write(msgs) |
|---|
| 95 | | os.unlink(potfile) |
|---|
| 96 | | |
|---|