﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26705	DjangoTranslation instance has no attribute 'plural'	Thejaswi Puthraya	nobody	"When you activate a language that is not supported by django, an error is raised during the internationalization. Here is a test to reproduce the error:

{{{
import datetime

from django.utils.translation import activate
from django.utils.timesince import timesince
from django.test import TestCase
from django.conf import settings

# Create your tests here.
class TmpTestCase(TestCase):
    def test_lang(self):
        today = datetime.datetime.now()
        yesterday = today - datetime.timedelta(minutes=5)

        tt = timesince(yesterday, now=today)
        self.assertEqual(tt, u""5\xa0minutes"")

        activate(""hi"")
        tt = timesince(yesterday, now=today)
        self.assertEqual(tt, u""5\xa0minutes"")

        activate(""as"")
        tt = timesince(yesterday, now=today)
        self.assertEqual(tt, u""5\xa0minutes"")
}}}

`as` is Assamese, a language that is currently not in django.

The error is

{{{
AttributeError                            Traceback (most recent call last)
<ipython-input-22-e5b829f6150e> in <module>()
----> 1 capfirst(ngettext(u""test"", u""tests"", 2))

/home/ubuntu/wg_env/local/lib/python2.7/site-packages/django/utils/translation/__init__.pyc in ngettext(singular, plural, number)
     78 
     79 def ngettext(singular, plural, number):
---> 80     return _trans.ngettext(singular, plural, number)
     81 
     82 

/home/ubuntu/wg_env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.pyc in ngettext(singular, plural, number)
    369     Returns a string on Python 3 and an UTF-8-encoded bytestring on Python 2.
    370     """"""
--> 371     return do_ntranslate(singular, plural, number, 'ngettext')
    372 
    373 if six.PY3:

/home/ubuntu/wg_env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.pyc in do_ntranslate(singular, plural, number, translation_function)
    356     t = getattr(_active, ""value"", None)
    357     if t is not None:
--> 358         return getattr(t, translation_function)(singular, plural, number)
    359     if _default is None:
    360         _default = translation(settings.LANGUAGE_CODE)

/usr/lib/python2.7/gettext.pyc in ngettext(self, msgid1, msgid2, n)
    368     def ngettext(self, msgid1, msgid2, n):
    369         try:
--> 370             tmsg = self._catalog[(msgid1, self.plural(n))]
    371             if self._output_charset:
    372                 return tmsg.encode(self._output_charset)

AttributeError: DjangoTranslation instance has no attribute 'plural'
}}}

Ideally, there shouldn't be an error.
"	Bug	closed	Internationalization	dev	Normal	fixed			Accepted	1	0	0	0	0	0
