~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/core/management/commands/makemessages.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import re
2
2
import os
3
3
import sys
 
4
import glob
4
5
import warnings
5
6
from itertools import dropwhile
6
7
from optparse import make_option
95
96
    if locale is not None:
96
97
        languages.append(locale)
97
98
    elif all:
98
 
        languages = [el for el in os.listdir(localedir) if not el.startswith('.')]
99
 
 
 
99
        locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) 
 
100
        languages = [os.path.basename(l) for l in locale_dirs]
 
101
    
100
102
    for locale in languages:
101
103
        if verbosity > 0:
102
104
            print "processing language", locale
145
147
                if file_ext in extensions:
146
148
                    src = open(os.path.join(dirpath, file), "rU").read()
147
149
                    thefile = '%s.py' % file
148
 
                    open(os.path.join(dirpath, thefile), "w").write(templatize(src))
 
150
                    try:
 
151
                        open(os.path.join(dirpath, thefile), "w").write(templatize(src))
 
152
                    except SyntaxError, msg:
 
153
                        msg = "%s (file: %s)" % (msg, os.path.join(dirpath, file))
 
154
                        raise SyntaxError(msg)
149
155
                if verbosity > 1:
150
156
                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
151
157
                cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
196
202
            help='Creates or updates the message files only for the given locale (e.g. pt_BR).'),
197
203
        make_option('--domain', '-d', default='django', dest='domain',
198
204
            help='The domain of the message files (default: "django").'),
199
 
        make_option('--verbosity', '-v', action='store', dest='verbosity',
200
 
            default='1', type='choice', choices=['0', '1', '2'],
201
 
            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
202
205
        make_option('--all', '-a', action='store_true', dest='all',
203
206
            default=False, help='Reexamines all source code and templates for new translation strings and updates all message files for all available languages.'),
204
207
        make_option('--extension', '-e', dest='extensions',