summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-11-04 13:50:21 -0800
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-11-04 13:50:21 -0800
commitcb2c3ce15443a0666646e8b60984830c38d3ecde (patch)
treece409e5c2c312f4c7d605ecbc8de767950ccf7b7 /django/utils
parent37a2e70cec08b365f3ec00bf4d91794ccb368daa (diff)
parentd0669843d0310a5c633548686ad8ce19404fc594 (diff)
Merge pull request #1821 from Bouke/tickets/14170
#14170 -- Reset i18n cache when settings changed
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/translation/trans_real.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 0f08056778..bf75ef17e2 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -11,6 +11,8 @@ from importlib import import_module
from threading import local
import warnings
+from django.dispatch import receiver
+from django.test.signals import setting_changed
from django.utils.encoding import force_str, force_text
from django.utils.functional import memoize
from django.utils._os import upath
@@ -47,6 +49,17 @@ accept_language_re = re.compile(r'''
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
+@receiver(setting_changed)
+def reset_cache(**kwargs):
+ """
+ Reset global state when LANGUAGES setting has been changed, as some
+ languages should no longer be accepted.
+ """
+ if kwargs['setting'] == 'LANGUAGES':
+ global _accepted
+ _accepted = {}
+
+
def to_locale(language, to_lower=False):
"""
Turns a language name (en-us) into a locale name (en_US). If 'to_lower' is