[1.8.x] Fixed #25295 -- Restored 'no active translation' after language override
Thanks David Nelson Adamec for the report and Tim Graham for the review.
Backport of 9324935c3
from master.
This commit is contained in:
parent
181528726e
commit
c177d0690e
|
@ -163,7 +163,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`).
|
||||
|
|
|
@ -74,6 +74,9 @@ class TranslationTests(TestCase):
|
|||
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