# HG changeset patch # User jruigrok # Date 1270976951 0 # Node ID 2d1c17275e5b157b4641e9cbf87c483a8506667e # Parent 58e76e09e7057b35f84fa4f720cf8ca32fc8487a Merged revisions 484-489 via svnmerge from http://svn.edgewall.org/repos/babel/trunk ........ r484 | jruigrok | 2010-02-19 14:16:08 +0100 (vr, 19 feb 2010) | 4 lines Fix testcase name typo. Switch to use a locale that uses a different singular and plural form instead of just one form for both singular and plural. ........ r485 | jruigrok | 2010-02-19 14:38:24 +0100 (vr, 19 feb 2010) | 2 lines Add a test for a locale with one plural form. ........ r486 | jruigrok | 2010-02-19 14:45:25 +0100 (vr, 19 feb 2010) | 3 lines Put the square brackets test after all the normal plural tests. It's more logical. ........ r487 | jruigrok | 2010-02-19 15:12:41 +0100 (vr, 19 feb 2010) | 2 lines More than two plural forms work nowadays. Adjust the test. ........ r488 | jruigrok | 2010-02-19 15:15:56 +0100 (vr, 19 feb 2010) | 2 lines Actually make the msgid_plural be a plural as per typical use case. ........ r489 | jruigrok | 2010-02-24 13:27:32 +0100 (wo, 24 feb 2010) | 2 lines Forgot to bump the copyright line. ........ diff --git a/babel/messages/tests/pofile.py b/babel/messages/tests/pofile.py --- a/babel/messages/tests/pofile.py +++ b/babel/messages/tests/pofile.py @@ -143,29 +143,39 @@ self.assertEqual(1, len(catalog)) self.assertEqual(0, len(catalog.obsolete)) - def test_singlular_plural_form(self): + def test_single_plural_form(self): buf = StringIO(r'''msgid "foo" -msgid_plural "foo" -msgstr[0] "Voh" -msgstr[1] "Vohs"''') # This is a bad po, ja_JP only uses msgstr[0] +msgid_plural "foos" +msgstr[0] "Voh"''') catalog = pofile.read_po(buf, locale='ja_JP') self.assertEqual(1, len(catalog)) self.assertEqual(1, catalog.num_plurals) message = catalog['foo'] self.assertEqual(1, len(message.string)) - + + def test_singular_plural_form(self): + buf = StringIO(r'''msgid "foo" +msgid_plural "foos" +msgstr[0] "Voh" +msgstr[1] "Vohs"''') + catalog = pofile.read_po(buf, locale='nl_NL') + self.assertEqual(1, len(catalog)) + self.assertEqual(2, catalog.num_plurals) + message = catalog['foo'] + self.assertEqual(2, len(message.string)) + def test_more_than_two_plural_forms(self): buf = StringIO(r'''msgid "foo" -msgid_plural "foo" +msgid_plural "foos" msgstr[0] "Voh" -msgstr[1] "Vohs"''') # last translation form is missing -#msgstr[2] "Vohss"''') +msgstr[1] "Vohs" +msgstr[2] "Vohss"''') catalog = pofile.read_po(buf, locale='lv_LV') self.assertEqual(1, len(catalog)) self.assertEqual(3, catalog.num_plurals) message = catalog['foo'] self.assertEqual(3, len(message.string)) - self.assertEqual('', message.string[2]) + self.assertEqual(u'Vohss', message.string[2]) def test_plural_with_square_brackets(self): buf = StringIO(r'''msgid "foo"