diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-11-04 10:48:27 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-11-04 10:48:27 +0000 |
| commit | 83aeb3c768173f48dc295c3194fecd705d1c05ac (patch) | |
| tree | f8ec0f35e86dce4291cea33a851a51e22b26bdd6 /tests | |
| parent | 0659391baf60902168f738f520f75ed20d835aa1 (diff) | |
Fixed #9988 -- Added support for translation contexts. Thanks, Claude Paroz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14450 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo | bin | 469 -> 611 bytes | |||
| -rw-r--r-- | tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po | 17 | ||||
| -rw-r--r-- | tests/regressiontests/i18n/tests.py | 18 | ||||
| -rw-r--r-- | tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo | bin | 484 -> 519 bytes | |||
| -rw-r--r-- | tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po | 4 | ||||
| -rw-r--r-- | tests/regressiontests/views/tests/i18n.py | 3 |
6 files changed, 41 insertions, 1 deletions
diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo Binary files differindex 2bc9343aa3..b662e9392d 100644 --- a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo +++ b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.mo diff --git a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po index 2fdcee5015..fa297e5683 100644 --- a/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po +++ b/tests/regressiontests/i18n/other/locale/de/LC_MESSAGES/django.po @@ -20,3 +20,20 @@ msgstr "" #: models.py:3 msgid "Date/time" msgstr "Datum/Zeit (LOCALE_PATHS)" + +#: models.py:5 +msgctxt "month name" +msgid "May" +msgstr "Mai" + +#: models.py:7 +msgctxt "verb" +msgid "May" +msgstr "Kann" + +#: models.py:9 +msgctxt "search" +msgid "%d result" +msgid_plural "%d results" +msgstr[0] "%d Resultat" +msgstr[1] "%d Resultate" diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index bac77b0dbc..615ffe822c 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -11,7 +11,7 @@ from django.test import TestCase from django.utils.formats import get_format, date_format, time_format, localize, localize_input, iter_format_modules from django.utils.numberformat import format as nformat from django.utils.safestring import mark_safe, SafeString, SafeUnicode -from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale +from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, pgettext, npgettext, to_locale from django.utils.importlib import import_module @@ -54,6 +54,22 @@ class TranslationTests(TestCase): s2 = pickle.loads(pickle.dumps(s1)) self.assertEqual(unicode(s2), "test") + def test_pgettext(self): + # Reset translation catalog to include other/locale/de + self.old_locale_paths = settings.LOCALE_PATHS + settings.LOCALE_PATHS += (os.path.join(os.path.dirname(os.path.abspath(__file__)), 'other', 'locale'),) + from django.utils.translation import trans_real + trans_real._active = {} + trans_real._translations = {} + activate('de') + + self.assertEqual(pgettext("unexisting", "May"), u"May") + self.assertEqual(pgettext("month name", "May"), u"Mai") + self.assertEqual(pgettext("verb", "May"), u"Kann") + self.assertEqual(npgettext("search", "%d result", "%d results", 4) % 4, u"4 Resultate") + + settings.LOCALE_PATHS = self.old_locale_paths + def test_string_concat(self): """ unicode(string_concat(...)) should not raise a TypeError - #4796 diff --git a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo Binary files differindex 356147cf11..537135ec95 100644 --- a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo +++ b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo diff --git a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po index 0d03f95845..9259aab91b 100644 --- a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po +++ b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po @@ -22,3 +22,7 @@ msgstr "il faut le traduire" msgid "Choose a time" msgstr "Choisir une heure" + +msgctxt "month name" +msgid "May" +msgstr "mai" diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py index 9a34738411..de023be444 100644 --- a/tests/regressiontests/views/tests/i18n.py +++ b/tests/regressiontests/views/tests/i18n.py @@ -30,6 +30,9 @@ 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) + if lang_code == 'fr': + # Message with context (msgctxt) + self.assertContains(response, "['month name\x04May'] = 'mai';", 1) class JsI18NTests(TestCase): |
