[1.1.X] Fixed #13388 - Refined changes made in r12384 in the JavaScript i18n admin view.

Backport of r13069 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13070 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2010-05-02 19:48:17 +00:00
parent ef0e10cccf
commit 99a512300c
2 changed files with 32 additions and 2 deletions

View File

@ -169,7 +169,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
except IOError: except IOError:
catalog = None catalog = None
if catalog is not None: if catalog is not None:
t.update(catalog._catalog) t = catalog._catalog
src = [LibHead] src = [LibHead]
plural = None plural = None
if '' in t: if '' in t:

View File

@ -2,6 +2,7 @@
import re import re
import datetime import datetime
from django.conf import settings
from django.core.files import temp as tempfile from django.core.files import temp as tempfile
from django.test import TestCase from django.test import TestCase
from django.contrib.auth.models import User, Permission from django.contrib.auth.models import User, Permission
@ -13,6 +14,7 @@ from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.forms.util import ErrorList from django.forms.util import ErrorList
from django.utils.cache import get_max_age from django.utils.cache import get_max_age
from django.utils.html import escape from django.utils.html import escape
from django.utils.translation import activate, deactivate
from django.utils.encoding import iri_to_uri from django.utils.encoding import iri_to_uri
# local test models # local test models
@ -262,6 +264,34 @@ class AdminViewBasicTest(TestCase):
"Changelist filter isn't showing options contained inside a model field 'choices' option named group." "Changelist filter isn't showing options contained inside a model field 'choices' option named group."
) )
def testI18NLanguageNonEnglishDefault(self):
"""
Check if the Javascript i18n view returns an empty language catalog
if the default language is non-English but the selected language
is English. See #13388 and #3594 for more details.
"""
old_language_code = settings.LANGUAGE_CODE
settings.LANGUAGE_CODE = 'fr'
activate('en-us')
response = self.client.get('/test_admin/admin/jsi18n/')
self.assertNotContains(response, 'Choisir une heure')
deactivate()
settings.LANGUAGE_CODE = old_language_code
def testI18NLanguageNonEnglishFallback(self):
"""
Makes sure that the fallback language is still working properly
in cases where the selected language cannot be found.
"""
old_language_code = settings.LANGUAGE_CODE
settings.LANGUAGE_CODE = 'fr'
activate('none')
response = self.client.get('/test_admin/admin/jsi18n/')
self.assertContains(response, 'Choisir une heure')
deactivate()
settings.LANGUAGE_CODE = old_language_code
class SaveAsTests(TestCase): class SaveAsTests(TestCase):
fixtures = ['admin-views-users.xml','admin-views-person.xml'] fixtures = ['admin-views-users.xml','admin-views-person.xml']
@ -1842,5 +1872,5 @@ class NeverCacheTests(TestCase):
def testJsi18n(self): def testJsi18n(self):
"Check the never-cache status of the Javascript i18n view" "Check the never-cache status of the Javascript i18n view"
response = self.client.get('/test_admin/jsi18n/') response = self.client.get('/test_admin/admin/jsi18n/')
self.failUnlessEqual(get_max_age(response), None) self.failUnlessEqual(get_max_age(response), None)