Ticket #11118: basecommand.diff
File basecommand.diff, 1.5 KB (added by , 15 years ago) |
---|
-
django/core/management/base.py
207 207 # like permissions, and those shouldn't contain any translations. 208 208 # But only do this if we can assume we have a working settings file, 209 209 # because django.utils.translation requires settings. 210 lang = None 210 211 if self.can_import_settings: 211 212 try: 212 213 from django.utils import translation 214 lang = translation.get_language() 213 215 translation.activate('en-us') 214 216 except ImportError, e: 215 217 # If settings should be available, but aren't, … … 232 234 except CommandError, e: 233 235 sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e))) 234 236 sys.exit(1) 237 if lang is not None: 238 # rolls back the temporary 'en-us' language to the one it 239 # was set to before (useful when called programmaticaly, e.g. 240 # in testing where the original language should be kept. 241 try: 242 from django.utils import translation 243 translation.activate(lang) 244 except ImportError, e: 245 # Should never happen (TM) since it worked above (lang != None) 246 sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e))) 247 sys.exit(1) 235 248 236 249 def validate(self, app=None, display_num_errors=False): 237 250 """