Loading django/utils/translation/__init__.py +6 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,12 @@ def lazy_number(func, resultclass, number=None, **kwargs): proxy = lazy(func, resultclass)(**kwargs) else: class NumberAwareString(resultclass): def __bool__(self): return bool(kwargs['singular']) def __nonzero__(self): # Python 2 compatibility return type(self).__bool__(self) def __mod__(self, rhs): if isinstance(rhs, dict) and number: try: Loading tests/i18n/tests.py +4 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,10 @@ class TranslationTests(SimpleTestCase): ) self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results") def test_ungettext_lazy_bool(self): self.assertTrue(ungettext_lazy('%d good result', '%d good results')) self.assertFalse(ungettext_lazy('', '')) @override_settings(LOCALE_PATHS=extended_locale_paths) def test_pgettext(self): trans_real._active = local() Loading Loading
django/utils/translation/__init__.py +6 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,12 @@ def lazy_number(func, resultclass, number=None, **kwargs): proxy = lazy(func, resultclass)(**kwargs) else: class NumberAwareString(resultclass): def __bool__(self): return bool(kwargs['singular']) def __nonzero__(self): # Python 2 compatibility return type(self).__bool__(self) def __mod__(self, rhs): if isinstance(rhs, dict) and number: try: Loading
tests/i18n/tests.py +4 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,10 @@ class TranslationTests(SimpleTestCase): ) self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results") def test_ungettext_lazy_bool(self): self.assertTrue(ungettext_lazy('%d good result', '%d good results')) self.assertFalse(ungettext_lazy('', '')) @override_settings(LOCALE_PATHS=extended_locale_paths) def test_pgettext(self): trans_real._active = local() Loading