1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00
Files
django/django/bin/make-messages.py
Georg Bauer 98d7430609 i18n patch - references #65
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@726 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2005-09-29 17:01:05 +00:00

48 lines
1.3 KiB
Python
Executable File

#!/usr/bin/python
import os
import sys
import getopt
basedir = None
if os.path.isdir(os.path.join('conf', 'locale')):
basedir = os.path.abspath(os.path.join('conf', 'locale'))
elif os.path.isdir('locale'):
basedir = os.path.abspath('locale')
else:
print "this script should be run from the django svn tree or your project or app tree"
sys.exit(1)
(opts, args) = getopt.getopt(sys.argv[1:], 'l:d:')
lang = None
domain = 'django'
for o, v in opts:
if o == '-l':
lang = v
elif o == '-d':
domain = v
if lang is None or domain is None:
print "usage: make-messages.py -l <language> -d <domain>"
sys.exit(1)
basedir = os.path.join(basedir, lang, 'LC_MESSAGES')
if not os.path.isdir(basedir):
os.makedirs(basedir)
lf = os.path.join(basedir, '%s.po' % domain)
for (dirpath, dirnames, filenames) in os.walk("."):
for file in filenames:
if file.endswith('.py') or file.endswith('.html'):
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
if os.path.isfile(lf):
cmd = 'xgettext -j -d %s -L Python -p %s %s' % (domain, basedir, os.path.join(dirpath, file))
else:
cmd = 'xgettext -d %s -L Python -p %s %s' % (domain, basedir, os.path.join(dirpath, file))
os.system(cmd)