﻿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
35278	`ngettext` result can be possibly undefined.	Piotr Kawula	Clara	"When the translation engine provide an invalid plural rule the `pluralidx` function can return invalid index which will cause the `ngettext` to return value that does not exist - `undefined`.
Same result can occur when the `newcatalog` contains invalid values, for example:

{{{
const newcatalog = {
  '%s something': [],
  ...
}
}}}

And in `ngettext` we have:
{{{
django.ngettext = function(singular, plural, count) {
 const value = django.catalog[singular];
 if (typeof value === 'undefined') {
    return (count == 1) ? singular : plural;
  } else {
    return value.constructor === Array ? value[django.pluralidx(count)] : value;
  }
};
}}}

Which in case of empty array go for `value[django.pluralidx(count)] ` which is undefined.


I think we want the `ngettext` function to return string always, if it does not find proper value in catalog, should default to the provided values.

It affects the previous versions too."	Bug	assigned	Internationalization	5.0	Normal		ngettext,catalog,i18n,internationalization,	Piotr Kawula Claude Paroz	Accepted	1	0	0	1	0	0
