1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Merge pull request #1821 from Bouke/tickets/14170

#14170 -- Reset i18n cache when settings changed
This commit is contained in:
Aymeric Augustin
2013-11-04 13:50:21 -08:00
4 changed files with 28 additions and 3 deletions

View File

@@ -427,7 +427,6 @@ class TransRealMixin(object):
trans_real._translations = {}
trans_real._active = local()
trans_real._default = None
trans_real._accepted = {}
trans_real._checked_languages = {}
def tearDown(self):

View File

@@ -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

View File

@@ -15,7 +15,7 @@ from django.http import (Http404, HttpResponse, HttpResponseRedirect,
from django.template import loader, Template, Context, TemplateDoesNotExist
from django.utils.http import http_date, parse_http_date
from django.utils.six.moves.urllib.parse import unquote
from django.utils.translation import ugettext as _, ugettext_noop
from django.utils.translation import ugettext as _, ugettext_lazy
def serve(request, path, document_root=None, show_indexes=False):
@@ -94,7 +94,7 @@ DEFAULT_DIRECTORY_INDEX_TEMPLATE = """
</body>
</html>
"""
template_translatable = ugettext_noop("Index of %(directory)s")
template_translatable = ugettext_lazy("Index of %(directory)s")
def directory_index(path, fullpath):