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 --- /dev/null +++ b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/djangojs.po @@ -0,0 +1,40 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: django tests\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-02-14 17:33+0100\n" +"PO-Revision-Date: 2011-01-21 21:37-0300\n" +"Last-Translator: Jannis Leidel \n" +"Language-Team: de \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#: models.py:7 +msgctxt "month name" +msgid "May" +msgstr "Mai" + +#: models.py:9 +msgctxt "verb" +msgid "May" +msgstr "Kann" + +#: models.py:11 +msgid "%s item" +msgid_plural "%s items" +msgstr[0] "%s Element" +msgstr[1] "%s Elemente" + +#: models.py:11 +msgctxt "search" +msgid "%s result" +msgid_plural "%s results" +msgstr[0] "%s Resultat" +msgstr[1] "%s Resultate" 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 --- /dev/null +++ b/tests/regressiontests/i18n/templates/javascript_i18n.html @@ -0,0 +1,44 @@ + + + + + + +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ + + diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index bce3d61..bf121f3 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -10,7 +10,7 @@ from threading import local from django.conf import settings from django.template import Template, Context from django.template.base import TemplateSyntaxError -from django.test import TestCase, RequestFactory +from django.test import LiveServerTestCase, TestCase, RequestFactory from django.test.utils import override_settings from django.utils import translation from django.utils.formats import (get_format, date_format, time_format, @@ -43,6 +43,8 @@ from .patterns.tests import (URLRedirectWithoutTrailingSlashTests, URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests, URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests) +from selenium.webdriver.firefox.webdriver import WebDriver + here = os.path.dirname(os.path.abspath(__file__)) @@ -1036,3 +1038,36 @@ class MultipleLocaleActivationTests(TestCase): t = Template("{% load i18n %}{% blocktrans %}No{% endblocktrans %}") with translation.override('nl'): self.assertEqual(t.render(Context({})), 'Nee') + + +class JavascriptI18nTests(LiveServerTestCase): + urls = 'regressiontests.i18n.urls' + + @classmethod + def setUpClass(cls): + cls.selenium = WebDriver() + super(JavascriptI18nTests, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + cls.selenium.quit() + super(JavascriptI18nTests, cls).tearDownClass() + + @override_settings(LANGUAGE_CODE='de') + def test_javascript_gettext(self): + extended_apps = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.other'] + with self.settings(INSTALLED_APPS=extended_apps): + self.selenium.get('%s%s' % (self.live_server_url, '/javascript_i18n/')) + + elem = self.selenium.find_element_by_id("gettext") + self.assertEqual(elem.text, "Auswählen") + elem = self.selenium.find_element_by_id("ngettext_sing") + self.assertEqual(elem.text, "1 Element") + elem = self.selenium.find_element_by_id("ngettext_plur") + self.assertEqual(elem.text, "455 Elemente") + elem = self.selenium.find_element_by_id("pgettext") + self.assertEqual(elem.text, "Kann") + elem = self.selenium.find_element_by_id("npgettext_sing") + self.assertEqual(elem.text, "1 Resultat") + elem = self.selenium.find_element_by_id("npgettext_plur") + self.assertEqual(elem.text, "455 Resultate") diff --git a/tests/regressiontests/i18n/urls.py b/tests/regressiontests/i18n/urls.py new file mode 100644 index 0000000..ec5e361 --- /dev/null +++ b/tests/regressiontests/i18n/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import patterns +from django.views.generic import TemplateView + + +urlpatterns = patterns('', + (r'^javascript_i18n/$', TemplateView.as_view(template_name='javascript_i18n.html')), + (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', + {'packages': ('django.contrib.admin','regressiontests.i18n.other'),} + ), +)