Ticket #19136: 19136-tests.diff
File 19136-tests.diff, 6.0 KB (added by , 12 years ago) |
---|
-
new file tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.po
diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.mo b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.mo new file mode 100644 index 0000000..34ba691 Binary files /dev/null and b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.mo differ diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.po b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.po new file mode 100644 index 0000000..88cc35e
- + 1 # SOME DESCRIPTIVE TITLE. 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 # This file is distributed under the same license as the PACKAGE package. 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 5 # 6 msgid "" 7 msgstr "" 8 "Project-Id-Version: django tests\n" 9 "Report-Msgid-Bugs-To: \n" 10 "POT-Creation-Date: 2010-02-14 17:33+0100\n" 11 "PO-Revision-Date: 2011-01-21 21:37-0300\n" 12 "Last-Translator: Jannis Leidel <jannis@leidel.info>\n" 13 "Language-Team: de <de@li.org>\n" 14 "MIME-Version: 1.0\n" 15 "Content-Type: text/plain; charset=UTF-8\n" 16 "Content-Transfer-Encoding: 8bit\n" 17 "Plural-Forms: nplurals=2; plural=(n != 1)\n" 18 19 #: models.py:7 20 msgctxt "month name" 21 msgid "May" 22 msgstr "Mai" 23 24 #: models.py:9 25 msgctxt "verb" 26 msgid "May" 27 msgstr "Kann" 28 29 #: models.py:11 30 msgid "%s item" 31 msgid_plural "%s items" 32 msgstr[0] "%s Element" 33 msgstr[1] "%s Elemente" 34 35 #: models.py:11 36 msgctxt "search" 37 msgid "%s result" 38 msgid_plural "%s results" 39 msgstr[0] "%s Resultat" 40 msgstr[1] "%s Resultate" -
new file tests/regressiontests/i18n/templates/javascript_i18n.html
diff --git a/tests/regressiontests/i18n/templates/javascript_i18n.html b/tests/regressiontests/i18n/templates/javascript_i18n.html new file mode 100644 index 0000000..49b22f4
- + 1 <html> 2 <head> 3 <script type="text/javascript" src="/jsi18n/"></script> 4 </head> 5 6 <body> 7 <p id="gettext"> 8 <script type="text/javascript"> 9 document.write(gettext("Choose")); 10 </script> 11 </p> 12 13 <p id="ngettext_sing"> 14 <script type="text/javascript"> 15 document.write(interpolate(ngettext("%s item", "%s items", 1), [1])); 16 </script> 17 </p> 18 19 <p id="ngettext_plur"> 20 <script type="text/javascript"> 21 document.write(interpolate(ngettext("%s item", "%s items", 455), [455])); 22 </script> 23 </p> 24 25 <p id="pgettext"> 26 <script type="text/javascript"> 27 document.write(pgettext("verb", "May")); 28 </script> 29 </p> 30 31 <p id="npgettext_sing"> 32 <script type="text/javascript"> 33 document.write(interpolate(npgettext("search", "%s result", "%s results", 1), [1])); 34 </script> 35 </p> 36 37 <p id="npgettext_plur"> 38 <script type="text/javascript"> 39 document.write(interpolate(npgettext("search", "%s result", "%s results", 455), [455])); 40 </script> 41 </p> 42 43 </body> 44 </html> -
tests/regressiontests/i18n/tests.py
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index bce3d61..bf121f3 100644
a b from threading import local 10 10 from django.conf import settings 11 11 from django.template import Template, Context 12 12 from django.template.base import TemplateSyntaxError 13 from django.test import TestCase, RequestFactory13 from django.test import LiveServerTestCase, TestCase, RequestFactory 14 14 from django.test.utils import override_settings 15 15 from django.utils import translation 16 16 from django.utils.formats import (get_format, date_format, time_format, … … from .patterns.tests import (URLRedirectWithoutTrailingSlashTests, 43 43 URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests, 44 44 URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests) 45 45 46 from selenium.webdriver.firefox.webdriver import WebDriver 47 46 48 47 49 here = os.path.dirname(os.path.abspath(__file__)) 48 50 … … class MultipleLocaleActivationTests(TestCase): 1036 1038 t = Template("{% load i18n %}{% blocktrans %}No{% endblocktrans %}") 1037 1039 with translation.override('nl'): 1038 1040 self.assertEqual(t.render(Context({})), 'Nee') 1041 1042 1043 class JavascriptI18nTests(LiveServerTestCase): 1044 urls = 'regressiontests.i18n.urls' 1045 1046 @classmethod 1047 def setUpClass(cls): 1048 cls.selenium = WebDriver() 1049 super(JavascriptI18nTests, cls).setUpClass() 1050 1051 @classmethod 1052 def tearDownClass(cls): 1053 cls.selenium.quit() 1054 super(JavascriptI18nTests, cls).tearDownClass() 1055 1056 @override_settings(LANGUAGE_CODE='de') 1057 def test_javascript_gettext(self): 1058 extended_apps = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.other'] 1059 with self.settings(INSTALLED_APPS=extended_apps): 1060 self.selenium.get('%s%s' % (self.live_server_url, '/javascript_i18n/')) 1061 1062 elem = self.selenium.find_element_by_id("gettext") 1063 self.assertEqual(elem.text, "Auswählen") 1064 elem = self.selenium.find_element_by_id("ngettext_sing") 1065 self.assertEqual(elem.text, "1 Element") 1066 elem = self.selenium.find_element_by_id("ngettext_plur") 1067 self.assertEqual(elem.text, "455 Elemente") 1068 elem = self.selenium.find_element_by_id("pgettext") 1069 self.assertEqual(elem.text, "Kann") 1070 elem = self.selenium.find_element_by_id("npgettext_sing") 1071 self.assertEqual(elem.text, "1 Resultat") 1072 elem = self.selenium.find_element_by_id("npgettext_plur") 1073 self.assertEqual(elem.text, "455 Resultate") -
new file tests/regressiontests/i18n/urls.py
diff --git a/tests/regressiontests/i18n/urls.py b/tests/regressiontests/i18n/urls.py new file mode 100644 index 0000000..ec5e361
- + 1 from django.conf.urls import patterns 2 from django.views.generic import TemplateView 3 4 5 urlpatterns = patterns('', 6 (r'^javascript_i18n/$', TemplateView.as_view(template_name='javascript_i18n.html')), 7 (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', 8 {'packages': ('django.contrib.admin','regressiontests.i18n.other'),} 9 ), 10 )