﻿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
29853	Exported jsi18n ngettext() function doesn't check existence of plural translation before attempting to access it	Mohamed Moustafa	nobody	"In https://docs.djangoproject.com/en/2.0/_modules/django/views/i18n/ the following exported javascript function
{{{
django.ngettext = function(singular, plural, count) {
      var value = django.catalog[singular];
      if (typeof(value) == 'undefined') {
        return (count == 1) ? singular : plural;
      } else {
        return value[django.pluralidx(count)];
      }
    };
}}}
doesn't check the existence of {{{value[1]}}} or {{{value[2]}}} before attempting to access them if {{{value}}} itself is defined. Therefore will return undefined if user attempts to access plural translation, when none is defined.

- If user provides no translations at all for singular or plural strings it will return formatted un-translated string (Works as expected)
- If user provides translations for singular and plural strings it will return formatted translated string (Works as expected)
- If user provides singular translation BUT no plural translation it will return undefined (Unexpected and extremely difficult to debug)

This function should rather fallback to singular translation OR use un-translated plural string in cases where a singular translation is provided but no plural translation is provided."	Uncategorized	new	Internationalization	2.1	Normal				Unreviewed	0	0	0	0	0	0
