1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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
This commit is contained in:
Jannis Leidel
2010-11-04 10:48:27 +00:00
parent 0659391baf
commit 83aeb3c768
13 changed files with 137 additions and 4 deletions

View File

@@ -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