From 16454ac35f6a24a04b23a9340b0d62c33edbc1ea Mon Sep 17 00:00:00 2001
From: Claude Paroz
Date: Sat, 26 Jan 2019 16:44:49 +0100
Subject: [PATCH] Fixed #29825 -- Fixed JS ngettext if the string is a
non-plural msgid in the catalog.
---
django/views/i18n.py | 2 +-
.../locale/de/LC_MESSAGES/djangojs.mo | Bin 615 -> 671 bytes
.../locale/de/LC_MESSAGES/djangojs.po | 3 +++
tests/view_tests/templates/jsi18n.html | 7 +++++++
tests/view_tests/tests/test_i18n.py | 2 ++
5 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/django/views/i18n.py b/django/views/i18n.py
index 3bd240ea3d..f684da23dc 100644
--- a/django/views/i18n.py
+++ b/django/views/i18n.py
@@ -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;
}
};
diff --git a/tests/view_tests/locale/de/LC_MESSAGES/djangojs.mo b/tests/view_tests/locale/de/LC_MESSAGES/djangojs.mo
index 34ba691029be7805899e6e28a03d36a5eb358d2f..4ff19729280dbf60622ae2f26ac3ed1ce247be5d 100644
GIT binary patch
delta 227
zcmaFPGM}~no)F7a1|VPqVi_Rz0b*_-t^r~YSOLTWK)e!&S%G*L5c2`?0U(wJ;`2bv
z0mQF?IERse;R}!!1L8y`1_l-&T>+$-fpjg9mH^U?Q1Mwn8mQa>CKSKC8@bE
Tx_IM$0mjL980So`Wl{nF!8#Ov
diff --git a/tests/view_tests/locale/de/LC_MESSAGES/djangojs.po b/tests/view_tests/locale/de/LC_MESSAGES/djangojs.po
index 03036e48ff..ed6ed226d2 100644
--- a/tests/view_tests/locale/de/LC_MESSAGES/djangojs.po
+++ b/tests/view_tests/locale/de/LC_MESSAGES/djangojs.po
@@ -39,3 +39,6 @@ msgid "%s result"
msgid_plural "%s results"
msgstr[0] "%s Resultat"
msgstr[1] "%s Resultate"
+
+msgid "Image"
+msgstr "Bild"
diff --git a/tests/view_tests/templates/jsi18n.html b/tests/view_tests/templates/jsi18n.html
index df1c4b400c..f0bd17c199 100644
--- a/tests/view_tests/templates/jsi18n.html
+++ b/tests/view_tests/templates/jsi18n.html
@@ -30,6 +30,13 @@
+
+
+
+
+