diff --git a/django/core/management/base.py b/django/core/management/base.py
index f1d8263..e728b90 100644
a
|
b
|
class BaseCommand(object):
|
203 | 203 | # like permissions, and those shouldn't contain any translations. |
204 | 204 | # But only do this if we can assume we have a working settings file, |
205 | 205 | # because django.utils.translation requires settings. |
| 206 | saved_lang = None |
206 | 207 | if self.can_import_settings: |
207 | 208 | try: |
208 | 209 | from django.utils import translation |
| 210 | saved_lang = translation.get_language() |
209 | 211 | translation.activate('en-us') |
210 | 212 | except ImportError, e: |
211 | 213 | # If settings should be available, but aren't, |
… |
… |
class BaseCommand(object):
|
232 | 234 | except CommandError, e: |
233 | 235 | self.stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e))) |
234 | 236 | sys.exit(1) |
| 237 | if saved_lang is not None: |
| 238 | translation.activate(saved_lang) |
235 | 239 | |
236 | 240 | def validate(self, app=None, display_num_errors=False): |
237 | 241 | """ |
diff --git a/tests/modeltests/user_commands/tests.py b/tests/modeltests/user_commands/tests.py
index bf74a98..896dd66 100644
a
|
b
|
from StringIO import StringIO
|
3 | 3 | from django.core import management |
4 | 4 | from django.core.management.base import CommandError |
5 | 5 | from django.test import TestCase |
| 6 | from django.utils import translation |
6 | 7 | |
7 | 8 | |
8 | 9 | class CommandTests(TestCase): |
… |
… |
class CommandTests(TestCase):
|
18 | 19 | self.assertEqual(out.getvalue(), |
19 | 20 | "I don't feel like dancing Jive.") |
20 | 21 | |
| 22 | def test_language_preserved(self): |
| 23 | out = StringIO() |
| 24 | with translation.override('fr'): |
| 25 | management.call_command('dance', stdout=out) |
| 26 | self.assertEqual(translation.get_language(), 'fr') |
| 27 | |
21 | 28 | def test_explode(self): |
22 | | self.assertRaises(CommandError, management.call_command, ('explode',)) |
23 | | No newline at end of file |
| 29 | self.assertRaises(CommandError, management.call_command, ('explode',)) |