Ticket #17379: 17379-1.diff

File 17379-1.diff, 1.8 KB (added by Claude Paroz, 13 years ago)

Add switch to commands to keep active language

  • django/core/management/base.py

    diff --git a/django/core/management/base.py b/django/core/management/base.py
    index db855e1..80cadda 100644
    a b class BaseCommand(object):  
    137137
    138138    # Configuration shortcuts that alter various logic.
    139139    can_import_settings = True
     140    keep_active_language = False
    140141    requires_model_validation = True
    141142    output_transaction = False  # Whether to wrap the output in a "BEGIN; COMMIT;"
    142143
    class BaseCommand(object):  
    210211        # But only do this if we can assume we have a working settings file,
    211212        # because django.utils.translation requires settings.
    212213        saved_lang = None
    213         if self.can_import_settings:
     214        if self.can_import_settings and not self.keep_active_language:
    214215            try:
    215216                from django.utils import translation
    216217                saved_lang = translation.get_language()
    217218                translation.activate('en-us')
     219                verbosity = int(options.get('verbosity'))
     220                if verbosity >= 2:
     221                    sys.stderr.write("Setting active language to 'en-us'\n")
    218222            except ImportError, e:
    219223                # If settings should be available, but aren't,
    220224                # raise the error and quit.
  • django/core/management/commands/shell.py

    diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
    index a8c9456..76ee477 100644
    a b class Command(NoArgsCommand):  
    99    )
    1010    help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
    1111    shells = ['ipython', 'bpython']
     12    keep_active_language = True
    1213    requires_model_validation = False
    1314
    1415    def ipython(self):
Back to Top