From: Christopher Lenz Date: Fri, 6 Jun 2008 21:51:48 +0000 (+0000) Subject: Fix for #97, compilation of message catalogs for locales with more than two plural... X-Git-Tag: 1.0~345 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5e71310261a17e46a4926d8710e62b556bcdbbc;p=thirdparty%2Fbabel.git Fix for #97, compilation of message catalogs for locales with more than two plural forms where the translations were empty was failing. --- diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py index 49069c31..bc0f3a8c 100644 --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -81,7 +81,7 @@ def write_mo(fileobj, catalog, use_fuzzy=False): msgstrs = [] for idx, string in enumerate(message.string): if not string: - msgstrs.append(message.id[idx]) + msgstrs.append(message.id[min(int(idx), 1)]) else: msgstrs.append(string) msgstr = '\x00'.join([ diff --git a/babel/messages/tests/mofile.py b/babel/messages/tests/mofile.py index adaa3e4f..3199c75f 100644 --- a/babel/messages/tests/mofile.py +++ b/babel/messages/tests/mofile.py @@ -47,6 +47,13 @@ class WriteMoTestCase(unittest.TestCase): self.assertEqual(u'Fuzzes', translations.ugettext('Fuzzes')) assert isinstance(translations.ugettext('Fuzzes'), unicode) + def test_more_plural_forms(self): + catalog2 = Catalog(locale='ru_RU') + catalog2.add(('Fuzz', 'Fuzzes'), ('', '', '')) + buf = StringIO() + mofile.write_mo(buf, catalog2) + + def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(mofile))