From 9e5aef461d4a67956dc93ca30f7536a067fd69c9 Mon Sep 17 00:00:00 2001 From: Wil Clouser Date: Mon, 22 Feb 2010 15:36:49 -0800 Subject: [PATCH] get_language() isn't reliable here, so we'll clear everything. This works on my local box --- lib/l10n/__init__.py | 12 +++++------- lib/l10n/tests/tests.py | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/l10n/__init__.py b/lib/l10n/__init__.py index 24fc770c8c..c6d59158c7 100644 --- a/lib/l10n/__init__.py +++ b/lib/l10n/__init__.py @@ -75,12 +75,10 @@ def activate(locale): jingo.env.install_gettext_translations(t) -def deactivate(): - """ Override django's utils.translation.deactivate(). Django continues - to cache a catalog even if you call their deactivate(). +def deactivate_all(): + """ Override django's utils.translation.deactivate_all(). Django continues + to cache a catalog even if you call their deactivate_all(). """ - locale = django_trans.get_language() - django_trans.deactivate() - if locale in django_trans._translations: - del django_trans._translations[locale] + django_trans.deactivate_all() + django_trans._translations = {} diff --git a/lib/l10n/tests/tests.py b/lib/l10n/tests/tests.py index 176736f746..4da6c1205d 100644 --- a/lib/l10n/tests/tests.py +++ b/lib/l10n/tests/tests.py @@ -25,7 +25,7 @@ def setup(): def teardown(): if os.path.isdir(LOCALEDIR): shutil.rmtree(LOCALEDIR) - l10n.deactivate() + l10n.deactivate_all() @with_setup(setup, teardown) @@ -67,13 +67,13 @@ def test_ungettext(): def test_activate(): - l10n.deactivate() + l10n.deactivate_all() l10n.activate('fr') # This string is from the AMO .po file a_text = "My Account" p_text = "Mon compte" eq_(p_text, _(a_text)) - l10n.deactivate() + l10n.deactivate_all() MO_DATA = '''\