mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #25295 -- Restored 'no active translation' after language override
Thanks David Nelson Adamec for the report and Tim Graham for the review.
This commit is contained in:
parent
4ce433e811
commit
9324935c3e
@ -164,7 +164,9 @@ class override(ContextDecorator):
|
||||
deactivate_all()
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
if self.deactivate:
|
||||
if self.old_language is None:
|
||||
deactivate_all()
|
||||
elif self.deactivate:
|
||||
deactivate()
|
||||
else:
|
||||
activate(self.old_language)
|
||||
|
@ -13,3 +13,5 @@ Bugfixes
|
||||
field that is both a foreign and primary key (:ticket:`24951`).
|
||||
|
||||
* Fixed a migrations crash with ``GenericForeignKey`` (:ticket:`25040`).
|
||||
* Made ``translation.override()`` clear the overridden language when a
|
||||
translation isn't initially active (:ticket:`25295`).
|
||||
|
@ -76,6 +76,9 @@ class TranslationTests(SimpleTestCase):
|
||||
self.assertEqual(get_language(), 'de')
|
||||
with translation.override(None):
|
||||
self.assertEqual(get_language(), None)
|
||||
with translation.override('pl'):
|
||||
pass
|
||||
self.assertEqual(get_language(), None)
|
||||
self.assertEqual(get_language(), 'de')
|
||||
finally:
|
||||
deactivate()
|
||||
|
Loading…
Reference in New Issue
Block a user