summaryrefslogtreecommitdiff
path: root/babel
diff options
context:
space:
mode:
authorMichael Birtwell <michael.birtwell@starleaf.com>2016-10-12 17:46:06 +0100
committerMichael Birtwell <michael.birtwell@starleaf.com>2016-11-21 14:32:49 +0000
commit7dfe6f9e01a4c157f69b6495ca1f293def3acc76 (patch)
tree0118cc01b60b597cc0e323eb39333068374b1732 /babel
parent2ba92312514fcac4902c624b571e8c8a7081658b (diff)
downloadbabel-7dfe6f9e01a4c157f69b6495ca1f293def3acc76.tar.gz
Fix read_pofile handling of missing plurals
Diffstat (limited to 'babel')
-rw-r--r--babel/messages/pofile.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py
index 47db8a9..696ec3e 100644
--- a/babel/messages/pofile.py
+++ b/babel/messages/pofile.py
@@ -135,13 +135,13 @@ class PoFileParser(object):
else:
msgid = self.messages[0].denormalize()
if isinstance(msgid, (list, tuple)):
- string = []
- for idx in range(self.catalog.num_plurals):
- try:
- string.append(self.translations[idx])
- except IndexError:
- string.append((idx, ''))
- string = tuple([t[1].denormalize() for t in string])
+ string = ['' for _ in range(self.catalog.num_plurals)]
+ for idx, translation in self.translations:
+ if idx >= self.catalog.num_plurals:
+ self._invalid_pofile("", self.offset, "msg has more translations than num_plurals of catalog")
+ continue
+ string[idx] = translation.denormalize()
+ string = tuple(string)
else:
string = self.translations[0][1].denormalize()
if self.context: