# HG changeset patch # User cmlenz # Date 1212789108 0 # Node ID 465a0582d308f7567e8d4b5524cd6017ad9d2c36 # Parent 35c19c01e4b552156a3080a72aed7c8d8ab84f2e 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 --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -81,7 +81,7 @@ 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 --- a/babel/messages/tests/mofile.py +++ b/babel/messages/tests/mofile.py @@ -47,6 +47,13 @@ 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))