#29825: ngettext returns invalid result if msgstr is also a valid msgid in the
same
catalog
-------------------------------------+-------------------------------------
Reporter: jeremy- | Owner: nobody
moffitt |
Type: | Status: new
Uncategorized |
Component: | Version: 2.1
Uncategorized | Keywords: ngettext
Severity: Normal | localization
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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
--
Ticket URL: <https://code.djangoproject.com/ticket/29825>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.2f2b93c414c0226b914a78cc8121792b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.