From b24af2f40508bc0d8aa0cef264e51c537ffb92bd Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Fri, 9 Dec 2016 15:07:25 +0100 Subject: [PATCH] Fixed #27418 -- Fixed occasional missing plural forms in JavaScriptCatalog. --- django/views/i18n.py | 4 +-- docs/releases/1.10.5.txt | 3 ++ .../locale/pt/LC_MESSAGES/djangojs.mo | Bin 0 -> 539 bytes .../locale/pt/LC_MESSAGES/djangojs.po | 27 ++++++++++++++++++ .../locale/ru/LC_MESSAGES/djangojs.mo | Bin 489 -> 597 bytes .../locale/ru/LC_MESSAGES/djangojs.po | 13 +++++++++ tests/view_tests/tests/test_i18n.py | 12 ++++++++ .../view_tests/tests/test_i18n_deprecated.py | 12 ++++++++ 8 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tests/view_tests/locale/pt/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/locale/pt/LC_MESSAGES/djangojs.po diff --git a/django/views/i18n.py b/django/views/i18n.py index c8cc5d043f..c3a813b0fe 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -253,7 +253,7 @@ def get_javascript_catalog(locale, domain, packages): else: raise TypeError(key) for k, v in pdict.items(): - catalog[k] = [v.get(i, '') for i in range(maxcnts[msgid] + 1)] + catalog[k] = [v.get(i, '') for i in range(maxcnts[k] + 1)] return catalog, plural @@ -401,7 +401,7 @@ class JavaScriptCatalog(View): else: raise TypeError(key) for k, v in pdict.items(): - catalog[k] = [v.get(i, '') for i in range(maxcnts[msgid] + 1)] + catalog[k] = [v.get(i, '') for i in range(maxcnts[k] + 1)] return catalog def get_context_data(self, **kwargs): diff --git a/docs/releases/1.10.5.txt b/docs/releases/1.10.5.txt index ac9270c3c0..381f956bc8 100644 --- a/docs/releases/1.10.5.txt +++ b/docs/releases/1.10.5.txt @@ -11,3 +11,6 @@ Bugfixes * Fixed a crash in the debug view if ``request.user`` can't be retrieved, such as if the database is unavailable (:ticket:`27567`). + +* Fixed occasional missing plural forms in ``JavaScriptCatalog`` + (:ticket:`27418`). diff --git a/tests/view_tests/locale/pt/LC_MESSAGES/djangojs.mo b/tests/view_tests/locale/pt/LC_MESSAGES/djangojs.mo new file mode 100644 index 0000000000000000000000000000000000000000..8407e242fc2a8a7dbd3459258cae93318118707c GIT binary patch literal 539 zcmbVIO;3YB5XG+xN6#MiZl(e)vBlbmEp3R{|-E?E|%F<$%+{sMoM7k`K+ zhoor}j!yRF&6~WPot>ZK!%q$40C9roAdV0LqK;bxLC_60Fl}P?9Me8Eu!2U2*mG7l-}+1g z3>!>~n3mHq!Dyo|prwLXQeNg%3F(mWG6=}j4L#ELLe~$j+|elV7K;H|d0NqwLColr zLjrd?S=J->gWxL9T0*7+J@i9w_bIbw=tIF3 cba%dbmU||_jJatI-E>n7AjsMyEAK;yr0ssI2 literal 0 HcmV?d00001 diff --git a/tests/view_tests/locale/pt/LC_MESSAGES/djangojs.po b/tests/view_tests/locale/pt/LC_MESSAGES/djangojs.po new file mode 100644 index 0000000000..ca643162e9 --- /dev/null +++ b/tests/view_tests/locale/pt/LC_MESSAGES/djangojs.po @@ -0,0 +1,27 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-09-15 19:15+0200\n" +"PO-Revision-Date: 2010-05-12 12:41-0300\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "{count} plural2" +msgid_plural "{count} plural2s" +msgstr[0] "{count} plural2" +msgstr[1] "{count} plural2s" + +msgid "{count} plural3" +msgid_plural "{count} plural3s" +msgstr[0] "{count} plural3" +msgstr[1] "{count} plural3s" diff --git a/tests/view_tests/locale/ru/LC_MESSAGES/djangojs.mo b/tests/view_tests/locale/ru/LC_MESSAGES/djangojs.mo index 21659a93d3ed61229fb0d6cb100f64391ded2b28..cb0a8d10db6f0c2c02abd14553ee632a368a00c7 100644 GIT binary patch delta 232 zcmaFKe3hmCo)F7a1|VPoVi_Q|0b*7ljsap2C;(z!AT9)A2_UWqVg(?c0mP<^3=BJg zv@{UE2eSEqG&d6igB6gL0@6SsFaR>a<}-tM&Kddn#i