mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #3594 - Added ability to discard the language catalog in the JavaScript i18n view in case the selected language is English but no English translation catalog actual exists, e.g. due to being the language translated from. Thanks to msaelices, aryx and Ramiro Morales.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12384 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Binary file not shown.
@@ -1,20 +0,0 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2007-09-15 16:45+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "this is to be translated"
|
||||
msgstr "this is to be translated in english"
|
||||
@@ -21,7 +21,7 @@ class I18NTests(TestCase):
|
||||
|
||||
def test_jsi18n(self):
|
||||
"""The javascript_catalog can be deployed with language settings"""
|
||||
for lang_code in ['es', 'fr', 'en', 'ru']:
|
||||
for lang_code in ['es', 'fr', 'ru']:
|
||||
activate(lang_code)
|
||||
catalog = gettext.translation('djangojs', locale_dir, [lang_code])
|
||||
trans_txt = catalog.ugettext('this is to be translated')
|
||||
@@ -30,3 +30,40 @@ class I18NTests(TestCase):
|
||||
# catalog['this is to be translated'] = 'same_that_trans_txt'
|
||||
# javascript_quote is used to be able to check unicode strings
|
||||
self.assertContains(response, javascript_quote(trans_txt), 1)
|
||||
|
||||
class JsI18NTests(TestCase):
|
||||
"""
|
||||
Tests django views in django/views/i18n.py that need to change
|
||||
settings.LANGUAGE_CODE.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.old_language_code = settings.LANGUAGE_CODE
|
||||
|
||||
def tearDown(self):
|
||||
settings.LANGUAGE_CODE = self.old_language_code
|
||||
|
||||
def test_jsi18n_with_missing_en_files(self):
|
||||
"""
|
||||
The javascript_catalog shouldn't load the fallback language in the
|
||||
case that the current selected language is actually the one translated
|
||||
from, and hence missing translation files completely.
|
||||
|
||||
This happens easily when you're translating from English to other
|
||||
languages and you've set settings.LANGUAGE_CODE to some other language
|
||||
than English.
|
||||
"""
|
||||
settings.LANGUAGE_CODE = 'es'
|
||||
activate('en-us')
|
||||
response = self.client.get('/views/jsi18n/')
|
||||
self.assertNotContains(response, 'esto tiene que ser traducido')
|
||||
|
||||
def test_jsi18n_fallback_language(self):
|
||||
"""
|
||||
Let's make sure that the fallback language is still working properly
|
||||
in cases where the selected language cannot be found.
|
||||
"""
|
||||
settings.LANGUAGE_CODE = 'fr'
|
||||
activate('fi')
|
||||
response = self.client.get('/views/jsi18n/')
|
||||
self.assertContains(response, 'il faut le traduire')
|
||||
|
||||
Reference in New Issue
Block a user