Use pybabel to extract the POT file

This commit is contained in:
Lukáš Lalinský
2012-05-29 19:53:54 +02:00
parent d9b1ca6020
commit 6c98611116
4 changed files with 1 additions and 79 deletions

View File

@@ -10,7 +10,7 @@ or fetch translations.
Updating the translation template after adding/removing some strings:
$ python po/update-pot.py
$ pybabel extract picard -o po/picard.pot
$ tx push -s
Fetching latest translations from Transifex:

View File

@@ -1,8 +0,0 @@
#!/usr/bin/env python
import os, shutil
for name in os.listdir('.'):
if name.startswith('picard-') and name.endswith('.po'):
newname = name[7:]
shutil.move(name, newname)

View File

@@ -1,31 +0,0 @@
#!/usr/bin/env python
import glob
import os.path
import shutil
sources = []
for root, dirs, files in os.walk(os.path.join('..', 'picard')):
for name in files:
if name.endswith('.py'):
sources.append(os.path.join(root, name))
cmd = "xgettext --copyright-holder=MusicBrainz " \
"--msgid-bugs-address=http://tickets.musicbrainz.org/ " \
"--add-comments=TR -L Python -d picard -o picard.pot --keyword=N_ " + \
" ".join(sources)
print cmd
os.system(cmd)
print
f = file('picard.pot', 'rt')
lines = f.readlines()
f.close()
f = file('picard.pot', 'wt')
for line in lines:
if line.startswith('#. TR: '):
line = '#. ' + line[7:]
f.write(line)
f.close()

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env python
import glob
import os.path
import shutil
sources = []
for root, dirs, files in os.walk(os.path.join('..', 'picard')):
for name in files:
if name.endswith('.py'):
sources.append(os.path.join(root, name))
cmd = "xgettext --copyright-holder=MusicBrainz " \
"--msgid-bugs-address=http://tickets.musicbrainz.org/ " \
"--add-comments=TR -L Python -d picard -o picard.pot --keyword=N_ " + \
" ".join(sources)
print cmd
os.system(cmd)
print
f = file('picard.pot', 'rt')
lines = f.readlines()
f.close()
f = file('picard.pot', 'wt')
for line in lines:
if line.startswith('#. TR: '):
line = '#. ' + line[7:]
f.write(line)
f.close()
for po in glob.glob("*.po"):
cmd = "msgmerge %s picard.pot -o new.%s" % (po, po)
print cmd
if os.system(cmd) == 0:
print "new.%s.po --> %s" % (po, po)
shutil.move("new.%s" % po, po)
os.system("msgfmt --statistics -c -v -o %s %s" % (os.devnull, po))
print