﻿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
29825	ngettext returns invalid result if msgstr is also a valid msgid in the same catalog	Jeremy Moffitt	nobody	"When ngettext is called with a msgid and that msgid has a msgstr that is also a valid msgid in the same catalog, the return value is not the msgstr, but instead is a single character from the msgstr. The problem seems to be that the msgstr is passed back into ngettext and since it has a valid value in the catalog, the code breaks into the else block and returns the 0 index character...

    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)];
      }
    };

The example in OpenStack Horizon (see link below) is that the French bundle contains the following:
msgid ""Image""
msgstr ""Image""

This should return ""Image"" ... instead it returns ""I"" ... the result of django.catalog[""Image""] being ""Image"" , which then breaks into the else block of the following if statement, resulting in a return value of ""Image""[0] ... or the capital letter ""I"". For languages where the msgstr does not match a valid key in the file, this problem does not occur.

see also openstack bug: https://bugs.launchpad.net/horizon/+bug/1778189"	Uncategorized	new	Uncategorized	2.1	Normal		ngettext localization		Unreviewed	0	0	0	0	0	0
