diff --git a/rosetta/tests/django.po.issue186.template b/rosetta/tests/django.po.issue186.template new file mode 100644 index 0000000..8cd290c --- /dev/null +++ b/rosetta/tests/django.po.issue186.template @@ -0,0 +1,38 @@ +# 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. +# +msgid "" +msgstr "" +"Project-Id-Version: Rosetta\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-21 12:21+0200\n" +"PO-Revision-Date: 2008-09-22 11:02\n" +"Last-Translator: Admin Admin \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Translated-Using: django-rosetta 0.4.RC2\n" + + +msgid "String 1" +msgstr "" + +msgid "String 2" +msgstr "" + +#. Translators: This is a text of the base template +#: templates/base.html:43 +msgid "String 3 with comment" +msgstr "" + +msgctxt "Context hint" +msgid "String 4" +msgstr "" + +msgid "%d Child" +msgid_plural "%d Childrenen" +msgstr[0] "%d Tchilt" +msgstr[1] "%d Tchildren" diff --git a/rosetta/tests/tests.py b/rosetta/tests/tests.py index 5d5d249..91149db 100644 --- a/rosetta/tests/tests.py +++ b/rosetta/tests/tests.py @@ -938,6 +938,35 @@ class RosettaTestCase(TestCase): r = self.client.get(url % 'adipisicing') self.assertContains(r, 'Lorem') + def test_45_issue186_plural_msg_search(self): + """Confirm that search of the .po file works for plurals. + """ + self.copy_po_file_from_template('./django.po.issue186.template') + url = self.xx_form_url + '?query=%s' + + # Here's the message entry we're considering: + # msgstr "%d Child" + # msgid_plural "%d Childrenen" + # msgstr[0] "%d Tchilt" + # msgstr[1] "%d Tchildren" + + # First, confirm that we don't ALWAYS see this particular message on the + # page. + r = self.client.get(url % 'kids') + self.assertNotContains(r, 'Child') + + # Search msgid_plural + r = self.client.get(url % 'childrenen') + self.assertContains(r, 'Child') + + # Search msgstr[0] + r = self.client.get(url % 'tchilt') + self.assertContains(r, 'Child') + + # Search msgstr[1] + r = self.client.get(url % 'tchildren') + self.assertContains(r, 'Child') + # Stubbed access control function def no_access(user): diff --git a/rosetta/views.py b/rosetta/views.py index 9a0d614..7c16e8c 100644 --- a/rosetta/views.py +++ b/rosetta/views.py @@ -620,7 +620,9 @@ class TranslationFormView(RosettaFileLevelMixin, TemplateView): return (six.text_type(e.msgstr) + six.text_type(e.msgid) + six.text_type(e.comment) + - u''.join([o[0] for o in e.occurrences]) + u''.join([o[0] for o in e.occurrences]) + + six.text_type(e.msgid_plural) + + u''.join(e.msgstr_plural.values()) ) entries = [e_ for e_ in self.po_file