Ticket #17008: 0a4b228-patch.diff

File 0a4b228-patch.diff, 5.2 KB (added by Andy Terra, 13 years ago)
  • django/core/management/commands/makemessages.py

    diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
    index 2c6e171..82eacdb 100755
    a b def copy_plural_forms(msgs, locale, domain, verbosity):  
    115115
    116116def make_messages(locale=None, domain='django', verbosity='1', all=False,
    117117        extensions=None, symlinks=False, ignore_patterns=[], no_wrap=False,
    118         no_obsolete=False):
     118        no_obsolete=False, keep_pot=False):
    119119    """
    120120    Uses the locale directory from the Django SVN tree or an application/
    121121    project to process all
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    201201                msgs, errors = _popen(cmd)
    202202                if errors:
    203203                    os.unlink(os.path.join(dirpath, thefile))
    204                     if os.path.exists(potfile):
     204                    if os.path.exists(potfile) and not keep_pot:
    205205                        os.unlink(potfile)
    206206                    raise CommandError(
    207207                        "errors happened while running xgettext on %s\n%s" %
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    248248                if errors:
    249249                    if thefile != file:
    250250                        os.unlink(os.path.join(dirpath, thefile))
    251                     if os.path.exists(potfile):
     251                    if os.path.exists(potfile) and not keep_pot:
    252252                        os.unlink(potfile)
    253253                    raise CommandError(
    254254                        "errors happened while running xgettext on %s\n%s" %
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    275275            msgs, errors = _popen('msguniq %s --to-code=utf-8 "%s"' %
    276276                                  (wrap, potfile))
    277277            if errors:
    278                 os.unlink(potfile)
     278                if not keep_pot:
     279                    os.unlink(potfile)
    279280                raise CommandError(
    280281                    "errors happened while running msguniq\n%s" % errors)
    281282            if os.path.exists(pofile):
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    287288                msgs, errors = _popen('msgmerge %s -q "%s" "%s"' %
    288289                                      (wrap, pofile, potfile))
    289290                if errors:
    290                     os.unlink(potfile)
     291                    if not keep_pot:
     292                        os.unlink(potfile)
    291293                    raise CommandError(
    292294                        "errors happened while running msgmerge\n%s" % errors)
    293295            elif not invoked_for_django:
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    299301                f.write(msgs)
    300302            finally:
    301303                f.close()
    302             os.unlink(potfile)
     304            if not keep_pot:
     305                os.unlink(potfile)
    303306            if no_obsolete:
    304307                msgs, errors = _popen('msgattrib %s -o "%s" --no-obsolete "%s"' %
    305308                                      (wrap, pofile, pofile))
    class Command(NoArgsCommand):  
    329332            default=False, help="Don't break long message lines into several lines"),
    330333        make_option('--no-obsolete', action='store_true', dest='no_obsolete',
    331334            default=False, help="Remove obsolete message strings"),
     335        make_option('--keep-pot', action='store_true', dest='keep_pot',
     336            default=False, help="Keep .pot file after making messages. Useful when debugging."),
     337
    332338    )
    333339    help = ( "Runs over the entire source tree of the current directory and "
    334340"pulls out all strings marked for translation. It creates (or updates) a message "
    class Command(NoArgsCommand):  
    352358        ignore_patterns = list(set(ignore_patterns))
    353359        no_wrap = options.get('no_wrap')
    354360        no_obsolete = options.get('no_obsolete')
     361        keep_pot = options.get('keep_pot')
    355362        if domain == 'djangojs':
    356363            extensions = handle_extensions(extensions or ['js'])
    357364        else:
    class Command(NoArgsCommand):  
    361368            sys.stdout.write('examining files with the extensions: %s\n'
    362369                             % get_text_list(list(extensions), 'and'))
    363370
    364         make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_obsolete)
     371        make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_obsolete, keep_pot)
  • docs/ref/django-admin.txt

    diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
    index c07b61c..0dfd325 100755
    a b Use the ``--no-default-ignore`` option to disable the default values of  
    475475Use the ``--no-wrap`` option to disable breaking long message lines into
    476476several lines in language files.
    477477
     478.. django-admin-option:: --keep-pot
     479
     480.. versionadded:: 1.4
     481
     482Use the ``--keep-pot`` option to prevent django from deleting the temporary .pot file
     483it generates before creating the .po file. This is useful for debugging errors which
     484may prevent the final language files from being created.
     485
    478486reset <appname appname ...>
    479487---------------------------
    480488
Back to Top