Ensured that the javascript_catalog view doesn't leak translations.

This commit is contained in:
Florian Apolloner 2013-05-05 15:52:07 +02:00
parent da85c8cf32
commit 371dbbe6e0
1 changed files with 8 additions and 7 deletions

View File

@ -6,7 +6,7 @@ from django import http
from django.conf import settings from django.conf import settings
from django.template import Context, Template from django.template import Context, Template
from django.utils import importlib from django.utils import importlib
from django.utils.translation import check_for_language, activate, to_locale, get_language from django.utils.translation import check_for_language, to_locale, get_language
from django.utils.encoding import smart_text from django.utils.encoding import smart_text
from django.utils.formats import get_format_modules, get_format from django.utils.formats import get_format_modules, get_format
from django.utils._os import upath from django.utils._os import upath
@ -205,17 +205,18 @@ def javascript_catalog(request, domain='djangojs', packages=None):
go to the djangojs domain. But this might be needed if you go to the djangojs domain. But this might be needed if you
deliver your JavaScript source from Django templates. deliver your JavaScript source from Django templates.
""" """
if request.GET: default_locale = to_locale(settings.LANGUAGE_CODE)
if 'language' in request.GET: locale = to_locale(get_language())
if request.GET and 'language' in request.GET:
if check_for_language(request.GET['language']): if check_for_language(request.GET['language']):
activate(request.GET['language']) locale = to_locale(request.GET['language'])
if packages is None: if packages is None:
packages = ['django.conf'] packages = ['django.conf']
if isinstance(packages, six.string_types): if isinstance(packages, six.string_types):
packages = packages.split('+') packages = packages.split('+')
packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS] packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS]
default_locale = to_locale(settings.LANGUAGE_CODE)
locale = to_locale(get_language())
t = {} t = {}
paths = [] paths = []
en_selected = locale.startswith('en') en_selected = locale.startswith('en')