changeset 330:465a0582d308 trunk

Fix for #97, compilation of message catalogs for locales with more than two plural forms where the translations were empty was failing.
author cmlenz
date Fri, 06 Jun 2008 21:51:48 +0000
parents 35c19c01e4b5
children afc5070a623c
files babel/messages/mofile.py babel/messages/tests/mofile.py
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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([
--- 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))
Copyright (C) 2012-2017 Edgewall Software