Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13388 - Refined changes made in r12384 in the JavaScript i18n …

…admin view.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13069 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 43bf086783ca60b477b0e9e19357eebf1ecb3fd9 1 parent cb02b92
Jannis Leidel authored May 02, 2010
2  django/views/i18n.py
@@ -219,7 +219,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
219 219
                 except IOError:
220 220
                     catalog = None
221 221
                 if catalog is not None:
222  
-                    t.update(catalog._catalog)
  222
+                    t = catalog._catalog
223 223
     src = [LibHead]
224 224
     plural = None
225 225
     if '' in t:
33  tests/regressiontests/admin_views/tests.py
@@ -2,6 +2,7 @@
2 2
 
3 3
 import re
4 4
 import datetime
  5
+from django.conf import settings
5 6
 from django.core.files import temp as tempfile
6 7
 from django.test import TestCase
7 8
 from django.contrib.auth import admin # Register auth models with the admin.
@@ -15,7 +16,7 @@
15 16
 from django.utils import formats
16 17
 from django.utils.cache import get_max_age
17 18
 from django.utils.html import escape
18  
-from django.utils.translation import get_date_formats
  19
+from django.utils.translation import get_date_formats, activate, deactivate
19 20
 from django.utils.encoding import iri_to_uri
20 21
 
21 22
 # local test models
@@ -271,6 +272,34 @@ def testChangeListNullBooleanDisplay(self):
271 272
         response = self.client.get("/test_admin/admin/admin_views/post/")
272 273
         self.failUnless('icon-unknown.gif' in response.content)
273 274
 
  275
+    def testI18NLanguageNonEnglishDefault(self):
  276
+        """
  277
+        Check if the Javascript i18n view returns an empty language catalog
  278
+        if the default language is non-English but the selected language
  279
+        is English. See #13388 and #3594 for more details.
  280
+        """
  281
+        old_language_code = settings.LANGUAGE_CODE
  282
+        settings.LANGUAGE_CODE = 'fr'
  283
+        activate('en-us')
  284
+        response = self.client.get('/test_admin/admin/jsi18n/')
  285
+        self.assertNotContains(response, 'Choisir une heure')
  286
+        deactivate()
  287
+        settings.LANGUAGE_CODE = old_language_code
  288
+
  289
+    def testI18NLanguageNonEnglishFallback(self):
  290
+        """
  291
+        Makes sure that the fallback language is still working properly
  292
+        in cases where the selected language cannot be found.
  293
+        """
  294
+        old_language_code = settings.LANGUAGE_CODE
  295
+        settings.LANGUAGE_CODE = 'fr'
  296
+        activate('none')
  297
+        response = self.client.get('/test_admin/admin/jsi18n/')
  298
+        self.assertContains(response, 'Choisir une heure')
  299
+        deactivate()
  300
+        settings.LANGUAGE_CODE = old_language_code
  301
+
  302
+
274 303
 class SaveAsTests(TestCase):
275 304
     fixtures = ['admin-views-users.xml','admin-views-person.xml']
276 305
 
@@ -1945,7 +1974,7 @@ def testPasswordChangeDone(self):
1945 1974
 
1946 1975
     def testJsi18n(self):
1947 1976
         "Check the never-cache status of the Javascript i18n view"
1948  
-        response = self.client.get('/test_admin/jsi18n/')
  1977
+        response = self.client.get('/test_admin/admin/jsi18n/')
1949 1978
         self.failUnlessEqual(get_max_age(response), None)
1950 1979
 
1951 1980
 

0 notes on commit 43bf086

Please sign in to comment.
Something went wrong with that request. Please try again.