Django

Code

Changeset 7844

Show
Ignore:
Timestamp:
07/06/08 01:39:44 (2 months ago)
Author:
mtredinnick
Message:

Fixed #5522 -- Moved make-messages, compile-messages and daily-cleanup into django-admin.py.

They are now called "makemessages", "compilemessages" and "cleanup". This is
backwards incompatible for make-messages.py and compile-messages.py, although
the old executables still exist for now and print an error pointing the caller
to the right command to call.

This reduces the number of binaries and man pages Django needs to install.

Patch from Janis Leidel.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/bin/compile-messages.py

    r6701 r7844  
    11#!/usr/bin/env python 
    22 
    3 import optparse 
    4 import os 
    5 import sys 
     3if __name__ == "__main__": 
     4    import sys 
     5    name = sys.argv[0] 
     6    args = ' '.join(sys.argv[1:]) 
     7    print >> sys.stderr, "%s has been moved into django-admin.py" % name 
     8    print >> sys.stderr, 'Please run "django-admin.py compilemessages %s" instead.'% args 
     9    print >> sys.stderr 
     10    sys.exit(1) 
    611 
    7 try: 
    8     set 
    9 except NameError: 
    10     from sets import Set as set     # For Python 2.3 
    11  
    12  
    13 def compile_messages(locale=None): 
    14     basedirs = (os.path.join('conf', 'locale'), 'locale') 
    15     if os.environ.get('DJANGO_SETTINGS_MODULE'): 
    16         from django.conf import settings 
    17         basedirs += settings.LOCALE_PATHS 
    18  
    19     # Gather existing directories. 
    20     basedirs = set(map(os.path.abspath, filter(os.path.isdir, basedirs))) 
    21  
    22     if not basedirs: 
    23         print "This script should be run from the Django SVN tree or your project or app tree, or with the settings module specified." 
    24         sys.exit(1) 
    25  
    26     for basedir in basedirs: 
    27         if locale: 
    28             basedir = os.path.join(basedir, locale, 'LC_MESSAGES') 
    29         compile_messages_in_dir(basedir) 
    30  
    31 def compile_messages_in_dir(basedir): 
    32     for dirpath, dirnames, filenames in os.walk(basedir): 
    33         for f in filenames: 
    34             if f.endswith('.po'): 
    35                 sys.stderr.write('processing file %s in %s\n' % (f, dirpath)) 
    36                 pf = os.path.splitext(os.path.join(dirpath, f))[0] 
    37                 # Store the names of the .mo and .po files in an environment 
    38                 # variable, rather than doing a string replacement into the 
    39                 # command, so that we can take advantage of shell quoting, to 
    40                 # quote any malicious characters/escaping. 
    41                 # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html 
    42                 os.environ['djangocompilemo'] = pf + '.mo' 
    43                 os.environ['djangocompilepo'] = pf + '.po' 
    44                 if sys.platform == 'win32': # Different shell-variable syntax 
    45                     cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"' 
    46                 else: 
    47                     cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"' 
    48                 os.system(cmd) 
    49  
    50 def main(): 
    51     parser = optparse.OptionParser() 
    52     parser.add_option('-l', '--locale', dest='locale', 
    53             help="The locale to process. Default is to process all.") 
    54     parser.add_option('--settings', 
    55         help='Python path to settings module, e.g. "myproject.settings". If provided, all LOCALE_PATHS will be processed. If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be checked as well.') 
    56     options, args = parser.parse_args() 
    57     if len(args): 
    58         parser.error("This program takes no arguments") 
    59     if options.settings: 
    60         os.environ['DJANGO_SETTINGS_MODULE'] = options.settings 
    61     compile_messages(options.locale) 
    62  
    63 if __name__ == "__main__": 
    64     main() 
  • django/trunk/django/bin/daily_cleanup.py

    r5403 r7844  
    88""" 
    99 
    10 import datetime 
    11 from django.db import transaction 
    12 from django.contrib.sessions.models import Session 
    13  
    14 def clean_up(): 
    15     """Clean up expired sessions.""" 
    16     Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() 
    17     transaction.commit_unless_managed() 
     10from django.core import management 
    1811 
    1912if __name__ == "__main__": 
    20     clean_up(
     13    management.call_command('cleanup'
  • django/trunk/django/bin/make-messages.py

    r7473 r7844  
    11#!/usr/bin/env python 
    22 
    3 # Need to ensure that the i18n framework is enabled 
    4 from django.conf import settings 
    5 settings.configure(USE_I18N = True) 
     3if __name__ == "__main__": 
     4    import sys 
     5    name = sys.argv[0] 
     6    args = ' '.join(sys.argv[1:]) 
     7    print >> sys.stderr, "%s has been moved into django-admin.py" % name 
     8    print >> sys.stderr, 'Please run "django-admin.py makemessages %s" instead.'% args 
     9    print >> sys.stderr 
     10    sys.exit(1) 
    611 
    7 from django.utils.translation import templatize 
    8 import re 
    9 import os 
    10 import sys 
    11 import getopt 
    12 from itertools import dropwhile 
    13  
    14 pythonize_re = re.compile(r'\n\s*//') 
    15  
    16 def make_messages(): 
    17     localedir = None 
    18  
    19     if os.path.isdir(os.path.join('conf', 'locale')): 
    20         localedir = os.path.abspath(os.path.join('conf', 'locale')) 
    21     elif os.path.isdir('locale'): 
    22         localedir = os.path.abspath('locale') 
    23     else: 
    24         print "This script should be run from the django svn tree or your project or app tree." 
    25         print "If you did indeed run it from the svn checkout or your project or application," 
    26         print "maybe you are just missing the conf/locale (in the django tree) or locale (for project" 
    27         print "and application) directory?" 
    28         print "make-messages.py doesn't create it automatically, you have to create it by hand if" 
    29         print "you want to enable i18n for your project or application." 
    30         sys.exit(1) 
    31  
    32     (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va') 
    33  
    34     lang = None 
    35     domain = 'django' 
    36     verbose = False 
    37     all = False 
    38  
    39     for o, v in opts: 
    40         if o == '-l': 
    41             lang = v 
    42         elif o == '-d': 
    43             domain = v 
    44         elif o == '-v': 
    45             verbose = True 
    46         elif o == '-a': 
    47             all = True 
    48  
    49     if domain not in ('django', 'djangojs'): 
    50         print "currently make-messages.py only supports domains 'django' and 'djangojs'" 
    51         sys.exit(1) 
    52     if (lang is None and not all) or domain is None: 
    53         print "usage: make-messages.py -l <language>" 
    54         print "   or: make-messages.py -a" 
    55         sys.exit(1) 
    56  
    57     languages = [] 
    58  
    59     if lang is not None: 
    60         languages.append(lang) 
    61     elif all: 
    62         languages = [el for el in os.listdir(localedir) if not el.startswith('.')] 
    63  
    64     for lang in languages: 
    65  
    66         print "processing language", lang 
    67         basedir = os.path.join(localedir, lang, 'LC_MESSAGES') 
    68         if not os.path.isdir(basedir): 
    69             os.makedirs(basedir) 
    70  
    71         pofile = os.path.join(basedir, '%s.po' % domain) 
    72         potfile = os.path.join(basedir, '%s.pot' % domain) 
    73  
    74         if os.path.exists(potfile): 
    75             os.unlink(potfile) 
    76  
    77         all_files = [] 
    78         for (dirpath, dirnames, filenames) in os.walk("."): 
    79             all_files.extend([(dirpath, f) for f in filenames]) 
    80         all_files.sort() 
    81         for dirpath, file in all_files: 
    82             if domain == 'djangojs' and file.endswith('.js'): 
    83                 if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    84                 src = open(os.path.join(dirpath, file), "rb").read() 
    85                 src = pythonize_re.sub('\n#', src) 
    86                 open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 
    87                 thefile = '%s.py' % file 
    88                 cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile)) 
    89                 (stdin, stdout, stderr) = os.popen3(cmd, 't') 
    90                 msgs = stdout.read() 
    91                 errors = stderr.read() 
    92                 if errors: 
    93                     print "errors happened while running xgettext on %s" % file 
    94                     print errors 
    95                     sys.exit(8) 
    96                 old = '#: '+os.path.join(dirpath, thefile)[2:] 
    97                 new = '#: '+os.path.join(dirpath, file)[2:] 
    98                 msgs = msgs.replace(old, new) 
    99                 if os.path.exists(potfile): 
    100                     # Strip the header 
    101                     msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 
    102                 else: 
    103                     msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
    104                 if msgs: 
    105                     open(potfile, 'ab').write(msgs) 
    106                 os.unlink(os.path.join(dirpath, thefile)) 
    107             elif domain == 'django' and (file.endswith('.py') or file.endswith('.html')): 
    108                 thefile = file 
    109                 if file.endswith('.html'): 
    110                     src = open(os.path.join(dirpath, file), "rb").read() 
    111                     thefile = '%s.py' % file 
    112                     open(os.path.join(dirpath, thefile), "wb").write(templatize(src)) 
    113                 if verbose: 
    114                     sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    115                 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"' % ( 
    116                     domain, os.path.join(dirpath, thefile)) 
    117                 (stdin, stdout, stderr) = os.popen3(cmd, 't') 
    118                 msgs = stdout.read() 
    119                 errors = stderr.read() 
    120                 if errors: 
    121                     print "errors happened while running xgettext on %s" % file 
    122                     print errors 
    123                     sys.exit(8) 
    124                 if thefile != file: 
    125                     old = '#: '+os.path.join(dirpath, thefile)[2:] 
    126                     new = '#: '+os.path.join(dirpath, file)[2:] 
    127                     msgs = msgs.replace(old, new) 
    128                 if os.path.exists(potfile): 
    129                     # Strip the header 
    130                     msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 
    131                 else: 
    132                     msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
    133                 if msgs: 
    134                     open(potfile, 'ab').write(msgs) 
    135                 if thefile != file: 
    136                     os.unlink(os.path.join(dirpath, thefile)) 
    137  
    138         if os.path.exists(potfile): 
    139             (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b') 
    140             msgs = stdout.read() 
    141             errors = stderr.read() 
    142             if errors: 
    143                 print "errors happened while running msguniq" 
    144                 print errors 
    145                 sys.exit(8) 
    146             open(potfile, 'w').write(msgs) 
    147             if os.path.exists(pofile): 
    148                 (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b') 
    149                 msgs = stdout.read() 
    150                 errors = stderr.read() 
    151                 if errors: 
    152                     print "errors happened while running msgmerge" 
    153                     print errors 
    154                     sys.exit(8) 
    155             open(pofile, 'wb').write(msgs) 
    156             os.unlink(potfile) 
    157  
    158 if __name__ == "__main__": 
    159     make_messages() 
  • django/trunk/django/core/management/base.py

    r7294 r7844  
    66from django.core.exceptions import ImproperlyConfigured 
    77from django.core.management.color import color_style 
     8 
     9try: 
     10    set 
     11except NameError: 
     12    from sets import Set as set     # For Python 2.3 
    813 
    914class CommandError(Exception): 
  • django/trunk/django/core/management/commands/makemessages.py

    • Property svn:executable deleted
    r7473 r7844  
    1 #!/usr/bin/env python 
    2  
    3 # Need to ensure that the i18n framework is enabled 
    4 from django.conf import settings 
    5 settings.configure(USE_I18N = True) 
    6  
    7 from django.utils.translation import templatize 
    81import re 
    92import os 
    103import sys 
    11 import getopt 
    124from itertools import dropwhile 
     5from optparse import make_option 
     6from django.core.management.base import CommandError, BaseCommand 
    137 
    148pythonize_re = re.compile(r'\n\s*//') 
    159 
    16 def make_messages(): 
    17     localedir = None 
     10def make_messages(locale=None, domain='django', verbosity='1', all=False): 
     11    """ 
     12    Uses the locale directory from the Django SVN tree or an application/ 
     13    project to process all  
     14    """ 
     15    # Need to ensure that the i18n framework is enabled 
     16    from django.conf import settings 
     17    settings.configure(USE_I18N = True) 
     18     
     19    from django.utils.translation import templatize 
    1820 
    1921    if os.path.isdir(os.path.join('conf', 'locale')): 
     
    2224        localedir = os.path.abspath('locale') 
    2325    else: 
    24         print "This script should be run from the django svn tree or your project or app tree." 
    25         print "If you did indeed run it from the svn checkout or your project or application," 
    26         print "maybe you are just missing the conf/locale (in the django tree) or locale (for project" 
    27         print "and application) directory?" 
    28         print "make-messages.py doesn't create it automatically, you have to create it by hand if" 
    29         print "you want to enable i18n for your project or application." 
    30         sys.exit(1) 
     26        raise CommandError("This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or application, maybe you are just missing the conf/locale (in the django tree) or locale (for project and application) directory? It is not created automatically, you have to create it by hand if you want to enable i18n for your project or application.") 
     27     
     28    if domain not in ('django', 'djangojs'): 
     29        raise CommandError("currently makemessages only supports domains 'django' and 'djangojs'") 
    3130 
    32     (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va') 
    33  
    34     lang = None 
    35     domain = 'django' 
    36     verbose = False 
    37     all = False 
    38  
    39     for o, v in opts: 
    40         if o == '-l': 
    41             lang = v 
    42         elif o == '-d': 
    43             domain = v 
    44         elif o == '-v': 
    45             verbose = True 
    46         elif o == '-a': 
    47             all = True 
    48  
    49     if domain not in ('django', 'djangojs'): 
    50         print "currently make-messages.py only supports domains 'django' and 'djangojs'" 
    51         sys.exit(1) 
    52     if (lang is None and not all) or domain is None: 
    53         print "usage: make-messages.py -l <language>" 
    54         print "   or: make-messages.py -a" 
    55         sys.exit(1) 
     31    if (locale is None and not all) or domain is None: 
     32        # backwards compatible error message 
     33        if not sys.argv[0].endswith("make-messages.py"): 
     34            message = "Type '%s help %s' for usage.\n" % (os.path.basename(sys.argv[0]), sys.argv[1]) 
     35        else: 
     36            message = "usage: make-messages.py -l <language>\n   or: make-messages.py -a\n" 
     37        raise CommandError(message) 
    5638 
    5739    languages = [] 
    58  
    59     if lang is not None: 
    60         languages.append(lang) 
     40    if locale is not None: 
     41        languages.append(locale) 
    6142    elif all: 
    6243        languages = [el for el in os.listdir(localedir) if not el.startswith('.')] 
    6344 
    64     for lang in languages: 
    65  
    66         print "processing language", lang 
    67         basedir = os.path.join(localedir, lang, 'LC_MESSAGES') 
     45    for locale in languages: 
     46        if verbosity > 0: 
     47            print "processing language", locale 
     48        basedir = os.path.join(localedir, locale, 'LC_MESSAGES') 
    6849        if not os.path.isdir(basedir): 
    6950            os.makedirs(basedir) 
     
    8162        for dirpath, file in all_files: 
    8263            if domain == 'djangojs' and file.endswith('.js'): 
    83                 if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
     64                if verbosity > 1: 
     65                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    8466                src = open(os.path.join(dirpath, file), "rb").read() 
    8567                src = pythonize_re.sub('\n#', src) 
     
    9173                errors = stderr.read() 
    9274                if errors: 
    93                     print "errors happened while running xgettext on %s" % file 
    94                     print errors 
    95                     sys.exit(8) 
     75                    raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) 
    9676                old = '#: '+os.path.join(dirpath, thefile)[2:] 
    9777                new = '#: '+os.path.join(dirpath, file)[2:] 
     
    11191                    thefile = '%s.py' % file 
    11292                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src)) 
    113                 if verbose
     93                if verbosity > 1
    11494                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    11595                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"' % ( 
     
    11999                errors = stderr.read() 
    120100                if errors: 
    121                     print "errors happened while running xgettext on %s" % file 
    122                     print errors 
    123                     sys.exit(8) 
     101                    raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) 
    124102                if thefile != file: 
    125103                    old = '#: '+os.path.join(dirpath, thefile)[2:] 
     
    141119            errors = stderr.read() 
    142120            if errors: 
    143                 print "errors happened while running msguniq" 
    144                 print errors 
    145                 sys.exit(8) 
     121                raise CommandError("errors happened while running msguniq\n%s" % errors) 
    146122            open(potfile, 'w').write(msgs) 
    147123            if os.path.exists(pofile): 
     
    150126                errors = stderr.read() 
    151127                if errors: 
    152                     print "errors happened while running msgmerge" 
    153                     print errors 
    154                     sys.exit(8) 
     128                    raise CommandError("errors happened while running msgmerge\n%s" % errors) 
    155129            open(pofile, 'wb').write(msgs) 
    156130            os.unlink(potfile) 
    157131 
    158 if __name__ == "__main__": 
    159     make_messages() 
     132 
     133class Command(BaseCommand): 
     134    option_list = BaseCommand.option_list + ( 
     135        make_option('--locale', '-l', default=None, dest='locale', 
     136            help='Creates or updates the message files only for the given locale (e.g. pt_BR).'), 
     137        make_option('--domain', '-d', default='django', dest='domain', 
     138            help='The domain of the message files (default: "django").'), 
     139        make_option('--verbosity', '-v', action='store', dest='verbosity', 
     140            default='1', type='choice', choices=['0', '1', '2'], 
     141            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 
     142        make_option('--all', '-a', action='store_true', dest='all', 
     143            default=False, help='Reexamines all source code and templates for new translation strings and updates all message files for all available languages.'), 
     144    ) 
     145    help = "Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory." 
     146 
     147    requires_model_validation = False 
     148    can_import_settings = False 
     149 
     150    def handle(self, *args, **options): 
     151        if len(args) != 0: 
     152            raise CommandError("Command doesn't accept any arguments") 
     153 
     154        locale = options.get('locale') 
     155        domain = options.get('domain') 
     156        verbosity = int(options.get('verbosity')) 
     157        process_all = options.get('all') 
     158 
     159        make_messages(locale, domain, verbosity, process_all) 
  • django/trunk/docs/contributing.txt

    r7751 r7844  
    393393      `i18n documentation`_. 
    394394    * Create a diff of the ``.po`` file against the current Subversion trunk. 
    395     * Make sure that `` bin/compile-messages.py -l <lang>`` runs without 
     395    * Make sure that `` django-admin.py compilemessages -l <lang>`` runs without 
    396396      producing any warnings. 
    397397    * Attach the patch to a ticket in Django's ticket system. 
  • django/trunk/docs/django-admin.txt

    r7704 r7844  
    8585 
    8686.. _Tutorial 2: ../tutorial02/ 
     87 
     88cleanup  
     89------- 
     90 
     91**New in Django development version** 
     92 
     93Can be run as a cronjob or directly to clean out old data from the database 
     94(only expired sessions at the moment). 
     95 
     96compilemessages 
     97--------------- 
     98 
     99**New in Django development version** 
     100 
     101Compiles .po files created with ``makemessages`` to .mo files for use with 
     102the builtin gettext support. See the `i18n documentation`_ for details. 
     103 
     104--locale 
     105~~~~~~~~ 
     106 
     107Use the ``--locale`` or ``-l`` option to specify the locale to process. 
     108If not provided all locales are processed. 
     109 
     110Example usage:: 
     111 
     112    django-admin.py compilemessages --locale=br_PT 
    87113 
    88114createcachetable <tablename> 
     
    362388 
    363389    django-admin.py loaddata --verbosity=2 
     390 
     391makemessages 
     392------------ 
     393 
     394**New in Django development version** 
     395 
     396Runs over the entire source tree of the current directory and pulls out all 
     397strings marked for translation. It creates (or updates) a message file in the 
     398conf/locale (in the django tree) or locale (for project and application) 
     399directory. After making changes to the messages files you need to compile them 
     400with ``compilemessages`` for use with the builtin gettext support. See the 
     401`i18n documentation`_ for details. 
     402 
     403.. _i18n documentation: ../i18n/#how-to-create-language-files 
     404 
     405--all 
     406~~~~~ 
     407 
     408Use the ``--all`` or ``-a`` option to update the message files for all 
     409available languages. 
     410 
     411Example usage:: 
     412 
     413    django-admin.py makemessages --all 
     414 
     415--locale 
     416~~~~~~~~ 
     417 
     418Use the ``--locale`` or ``-l`` option to specify the locale to process. 
     419 
     420Example usage:: 
     421 
     422    django-admin.py makemessages --locale=br_PT 
     423 
     424--domain 
     425~~~~~~~~ 
     426 
     427Use the ``--domain`` or ``-d`` option to change the domain of the messages files. 
     428Currently supported: 
     429 
     430        * ``django`` for all ``*.py`` and ``*.html`` files (default)  
     431        * ``djangojs`` for ``*.js`` files 
     432 
     433--verbosity 
     434~~~~~~~~~~~ 
     435 
     436Use ``--verbosity`` or ``-v`` to specify the amount of notification and debug 
     437information that ``django-admin.py`` should print to the console. 
     438 
     439        * ``0`` means no output. 
     440        * ``1`` means normal output (default). 
     441        * ``2`` means verbose output. 
     442 
     443Example usage:: 
     444 
     445    django-admin.py makemessages --verbosity=2 
    364446 
    365447reset <appname appname ...> 
  • django/trunk/docs/i18n.txt

    r7842 r7844  
    123123(The caveat with using variables or computed values, as in the previous two 
    124124examples, is that Django's translation-string-detecting utility, 
    125 ``make-messages.py``, won't be able to find these strings. More on 
    126 ``make-messages`` later.) 
     125``django-admin.py makemessages``, won't be able to find these strings. More on 
     126``makemessages`` later.) 
    127127 
    128128The strings you pass to ``_()`` or ``ugettext()`` can take placeholders, 
     
    394394language. Message files have a ``.po`` file extension. 
    395395 
    396 Django comes with a tool, ``bin/make-messages.py``, that automates the creation 
    397 and upkeep of these files. 
     396Django comes with a tool, ``django-admin.py makemessages``, that automates the 
     397creation and upkeep of these files.  
     398 
     399.. admonition:: A note to Django veterans 
     400 
     401    The old tool ``bin/make-messages.py`` has been moved to the command 
     402    ``django-admin.py makemessages`` to provide consistency throughout Django. 
    398403 
    399404To create or update a message file, run this command:: 
    400405 
    401     bin/make-messages.py -l de 
     406    django-admin.py makemessages -l de 
    402407 
    403408...where ``de`` is the language code for the message file you want to create. 
     
    424429.. admonition:: No gettext? 
    425430 
    426     If you don't have the ``gettext`` utilities installed, ``make-messages.py`` 
    427     will create empty files. If that's the case, either install the ``gettext`` 
    428     utilities or just copy the English message file 
    429     (``conf/locale/en/LC_MESSAGES/django.po``) and use it as a starting point; 
    430     it's just an empty translation file. 
     431    If you don't have the ``gettext`` utilities installed, 
     432    ``django-admin.py makemessages`` will create empty files. If that's the 
     433    case, either install the ``gettext`` utilities or just copy the English 
     434    message file (``conf/locale/en/LC_MESSAGES/django.po``) and use it as a 
     435    starting point; it's just an empty translation file. 
    431436 
    432437The format of ``.po`` files is straightforward. Each ``.po`` file contains a 
     
    441446    _("Welcome to my site.") 
    442447 
    443 ...then ``make-messages.py`` will have created a ``.po`` file containing th
    444 following snippet -- a message:: 
     448...then ``django-admin.py makemessages`` will have created a ``.po`` fil
     449containing the following snippet -- a message:: 
    445450 
    446451    #: path/to/python/module.py:23 
     
    477482update all message files for **all** languages, run this:: 
    478483 
    479     make-messages.py -a 
     484    django-admin.py makemessages -a 
    480485 
    481486Compiling message files 
     
    484489After you create your message file -- and each time you make changes to it -- 
    485490you'll need to compile it into a more efficient form, for use by ``gettext``. 
    486 Do this with the ``bin/compile-messages.py`` utility. 
     491Do this with the ``django-admin.py compilemessages`` utility. 
    487492 
    488493This tool runs over all available ``.po`` files and creates ``.mo`` files, 
    489494which are binary files optimized for use by ``gettext``. In the same directory 
    490 from which you ran ``make-messages.py``, run ``compile-messages.py`` like 
    491 this:: 
    492  
    493    bin/compile-messages.py 
     495from which you ran ``django-admin.py makemessages``, run 
     496``django-admin.py compilemessages`` like this:: 
     497 
     498   django-admin.py compilemessages 
    494499 
    495500That's it. Your translations are ready for use. 
     501 
     502.. admonition:: A note to Django veterans 
     503 
     504    The old tool ``bin/compile-messages.py`` has been moved to the command 
     505    ``django-admin.py compilemessages`` to provide consistency throughout 
     506    Django. 
    496507 
    497508.. admonition:: A note to translators 
     
    599610          ) 
    600611 
    601       With this arrangement, ``make-messages.py`` will still find and mark 
    602       these strings for translation, but the translation won't happen at 
    603       runtime -- so you'll have to remember to wrap the languages in the *real* 
     612      With this arrangement, ``django-admin.py makemessages`` will still find 
     613      and mark these strings for translation, but the translation won't happen 
     614      at runtime -- so you'll have to remember to wrap the languages in the *real* 
    604615      ``ugettext()`` in any code that uses ``LANGUAGES`` at runtime. 
    605616 
     
    678689    * ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)`` 
    679690 
    680 To create message files, you use the same ``make-messages.py`` tool as with the 
    681 Django message files. You only need to be in the right place -- in the directory 
    682 where either the ``conf/locale`` (in case of the source tree) or the ``locale/`` 
    683 (in case of app messages or project messages) directory are located. And you 
    684 use the same ``compile-messages.py`` to produce the binary ``django.mo`` files 
    685 that are used by ``gettext``. 
    686  
    687 You can also run ``compile-message.py --settings=path.to.settings`` to make 
    688 the compiler process all the directories in your ``LOCALE_PATHS`` setting. 
     691To create message files, you use the same ``django-admin.py makemessages`` 
     692tool as with the Django message files. You only need to be in the right place 
     693-- in the directory where either the ``conf/locale`` (in case of the source 
     694tree) or the ``locale/`` (in case of app messages or project messages) 
     695directory are located. And you use the same ``django-admin.py compilemessages`` 
     696to produce the binary ``django.mo`` files that are used by ``gettext``. 
     697 
     698You can also run ``django-admin.py compilemessages --settings=path.to.settings`` 
     699to make the compiler process all the directories in your ``LOCALE_PATHS`` 
     700setting. 
    689701 
    690702Application message files are a bit complicated to discover -- they need the 
     
    696708be used in other projects, you might want to use app-specific translations. 
    697709But using app-specific translations and project translations could produce 
    698 weird problems with ``make-messages``: ``make-messages`` will traverse all 
     710weird problems with ``makemessages``: ``makemessages`` will traverse all 
    699711directories below the current path and so might put message IDs into the 
    700712project message file that are already in application message files. 
     
    702714The easiest way out is to store applications that are not part of the project 
    703715(and so carry their own translations) outside the project tree. That way, 
    704 ``make-messages`` on the project level will only translate strings that ar
    705 connected to your explicit project and not strings that are distributed 
    706 independently. 
     716``django-admin.py makemessages`` on the project level will only translat
     717strings that are connected to your explicit project and not strings that are 
     718distributed independently. 
    707719 
    708720The ``set_language`` redirect view 
     
    859871 
    860872You create and update the translation catalogs the same way as the other 
    861 Django translation catalogs -- with the make-messages.py tool. The only 
    862 difference is you need to provide a ``-d djangojs`` parameter, like this:: 
    863  
    864     make-messages.py -d djangojs -l de 
     873Django translation catalogs -- with the django-admin.py makemessages tool. The 
     874only difference is you need to provide a ``-d djangojs`` parameter, like this:: 
     875 
     876    django-admin.py makemessages -d djangojs -l de 
    865877 
    866878This would create or update the translation catalog for JavaScript for German. 
    867 After updating translation catalogs, just run ``compile-messages.py`` the same 
    868 way as you do with normal Django translation catalogs. 
     879After updating translation catalogs, just run ``django-admin.py compilemessages`` 
     880the same way as you do with normal Django translation catalogs. 
    869881 
    870882Specialties of Django translation 
  • django/trunk/docs/man/django-admin.1

    r7294 r7844  
    1 .TH "django-admin.py" "1" "June 2007" "Django Project" "" 
     1.TH "django-admin.py" "1" "March 2008" "Django Project" "" 
    22.SH "NAME" 
    33django\-admin.py \- Utility script for the Django web framework 
     
    2222Prints the admin\-index template snippet for the given app name(s). 
    2323.TP 
     24.BI cleanup 
     25Cleans out old data from the database (only expired sessions at the moment). 
     26.TP 
     27.BI "compilemessages [" "\-\-locale=LOCALE" "]" 
     28Compiles .po files to .mo files for use with builtin gettext support. 
     29.TP 
    2430.BI "createcachetable [" "tablename" "]" 
    2531Creates the table needed to use the SQL cache backend 
     
    4349.B sqlall 
    4450for the given app(s) in the current database. 
     51.TP 
     52.BI "makemessages [" "\-\-locale=LOCALE" "] [" "\-\-domain=DOMAIN" "] [" "\-\-all" "]" 
     53Runs over the entire source tree of the current directory and pulls out all 
     54strings marked for translation. It creates (or updates) a message file in the 
     55conf/locale (in the django tree) or locale (for project and application) directory. 
    4556.TP 
    4657.BI "reset [" "appname ..." "]" 
     
    137148.I \-\-adminmedia=ADMIN_MEDIA_PATH 
    138149Specifies the directory from which to serve admin media when using the development server. 
    139  
     150.TP 
     151.I \-l, \-\-locale=LOCALE 
     152The locale to process when using makemessages or compilemessages. 
     153.TP 
     154.I \-d, \-\-domain=DOMAIN 
     155The domain of the message files (default: "django") when using makemessages. 
     156.TP 
     157.I \-a, \-\-all 
     158Process all available locales when using makemessages. 
    140159.SH "ENVIRONMENT" 
    141160.TP 
  • django/trunk/docs/sessions.txt

    r7654 r7844  
    350350the row never gets deleted. 
    351351 
    352 Django provides a sample clean-up script in ``django/bin/daily_cleanup.py``. 
     352Django provides a sample clean-up script in ``django-admin.py cleanup``. 
    353353That script deletes any session in the session table whose ``expire_date`` is 
    354354in the past -- but your application may have different requirements. 
  • django/trunk/docs/settings.txt

    r7814 r7844  
    683683    ) 
    684684 
    685 With this arrangement, ``make-messages.py`` will still find and mark these 
    686 strings for translation, but the translation won't happen at runtime -- so 
    687 you'll have to remember to wrap the languages in the *real* ``gettext()`` in 
    688 any code that uses ``LANGUAGES`` at runtime. 
     685With this arrangement, ``django-admin.py makemessages`` will still find and 
     686mark these strings for translation, but the translation won't happen at 
     687runtime -- so you'll have to remember to wrap the languages in the *real* 
     688``gettext()`` in any code that uses ``LANGUAGES`` at runtime. 
    689689 
    690690LOCALE_PATHS 
  • django/trunk/extras/django_bash_completion

    r7727 r7844  
    4343 
    4444    # Standalone options 
    45     opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version
     45    opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version --locale --domain
    4646    # Actions 
    47     actions="adminindex createcachetable createsuperuser dbshell diffsettings \ 
    48              dumpdata flush inspectdb loaddata reset runfcgi runserver
    49              shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes
    50              sqlreset sqlsequencereset startapp startproject
    51              syncdb test validate" 
     47    actions="adminindex createcachetable createsuperuser compilemessages \ 
     48             dbshell diffsettings dumpdata flush inspectdb loaddata
     49             makemessages reset runfcgi runserver shell sql sqlall sqlclear
     50             sqlcustom sqlflush sqlindexes sqlreset sqlsequencereset startapp
     51             startproject syncdb test validate" 
    5252    # Action's options 
    5353    action_shell_opts="--plain" 
     
    119119                ;; 
    120120 
    121             createcachetable|dbshell|diffsettings| \ 
    122             inspectdb|runserver|startapp|startproject|syncdb| \ 
     121            createcachetable|cleanup|compilemessages|dbshell| \ 
     122            diffsettings|inspectdb|makemessages| \ 
     123            runserver|startapp|startproject|syncdb| \ 
    123124            validate) 
    124125                COMPREPLY=()