mirror of https://github.com/django/django.git
[2.2.x] Fixed #29825 -- Fixed JS ngettext if the string is a non-plural msgid in the catalog.
Backport of 16454ac35f
from master.
This commit is contained in:
parent
728358c5cf
commit
caaa01142d
|
@ -113,7 +113,7 @@ js_catalog_template = r"""
|
|||
if (typeof(value) == 'undefined') {
|
||||
return (count == 1) ? singular : plural;
|
||||
} else {
|
||||
return value[django.pluralidx(count)];
|
||||
return value.constructor === Array ? value[django.pluralidx(count)] : value;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
|
@ -39,3 +39,6 @@ msgid "%s result"
|
|||
msgid_plural "%s results"
|
||||
msgstr[0] "%s Resultat"
|
||||
msgstr[1] "%s Resultate"
|
||||
|
||||
msgid "Image"
|
||||
msgstr "Bild"
|
||||
|
|
|
@ -30,6 +30,13 @@
|
|||
</script>
|
||||
</p>
|
||||
|
||||
<p id="ngettext_onnonplural">
|
||||
<!-- The po file only contains the non plural "Image" string. -->
|
||||
<script type="text/javascript">
|
||||
document.write(interpolate(ngettext("Image", "Images", 5), [1]));
|
||||
</script>
|
||||
</p>
|
||||
|
||||
<p id="pgettext">
|
||||
<script type="text/javascript">
|
||||
document.write(pgettext("verb", "May"));
|
||||
|
|
|
@ -435,6 +435,8 @@ class I18nSeleniumTests(SeleniumTestCase):
|
|||
self.assertEqual(elem.text, "1 Element")
|
||||
elem = self.selenium.find_element_by_id("ngettext_plur")
|
||||
self.assertEqual(elem.text, "455 Elemente")
|
||||
elem = self.selenium.find_element_by_id("ngettext_onnonplural")
|
||||
self.assertEqual(elem.text, "Bild")
|
||||
elem = self.selenium.find_element_by_id("pgettext")
|
||||
self.assertEqual(elem.text, "Kann")
|
||||
elem = self.selenium.find_element_by_id("npgettext_sing")
|
||||
|
|
Loading…
Reference in New Issue