mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #29825 -- Fixed JS ngettext if the string is a non-plural msgid in the catalog.
This commit is contained in:
parent
1e92407f83
commit
16454ac35f
@ -113,7 +113,7 @@ js_catalog_template = r"""
|
|||||||
if (typeof(value) == 'undefined') {
|
if (typeof(value) == 'undefined') {
|
||||||
return (count == 1) ? singular : plural;
|
return (count == 1) ? singular : plural;
|
||||||
} else {
|
} 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"
|
msgid_plural "%s results"
|
||||||
msgstr[0] "%s Resultat"
|
msgstr[0] "%s Resultat"
|
||||||
msgstr[1] "%s Resultate"
|
msgstr[1] "%s Resultate"
|
||||||
|
|
||||||
|
msgid "Image"
|
||||||
|
msgstr "Bild"
|
||||||
|
@ -30,6 +30,13 @@
|
|||||||
</script>
|
</script>
|
||||||
</p>
|
</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">
|
<p id="pgettext">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.write(pgettext("verb", "May"));
|
document.write(pgettext("verb", "May"));
|
||||||
|
@ -435,6 +435,8 @@ class I18nSeleniumTests(SeleniumTestCase):
|
|||||||
self.assertEqual(elem.text, "1 Element")
|
self.assertEqual(elem.text, "1 Element")
|
||||||
elem = self.selenium.find_element_by_id("ngettext_plur")
|
elem = self.selenium.find_element_by_id("ngettext_plur")
|
||||||
self.assertEqual(elem.text, "455 Elemente")
|
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")
|
elem = self.selenium.find_element_by_id("pgettext")
|
||||||
self.assertEqual(elem.text, "Kann")
|
self.assertEqual(elem.text, "Kann")
|
||||||
elem = self.selenium.find_element_by_id("npgettext_sing")
|
elem = self.selenium.find_element_by_id("npgettext_sing")
|
||||||
|
Loading…
Reference in New Issue
Block a user