diff options
author | Michael Birtwell <michael.birtwell@starleaf.com> | 2016-10-12 17:46:06 +0100 |
---|---|---|
committer | Michael Birtwell <michael.birtwell@starleaf.com> | 2016-11-21 14:32:49 +0000 |
commit | 7dfe6f9e01a4c157f69b6495ca1f293def3acc76 (patch) | |
tree | 0118cc01b60b597cc0e323eb39333068374b1732 /babel | |
parent | 2ba92312514fcac4902c624b571e8c8a7081658b (diff) | |
download | babel-7dfe6f9e01a4c157f69b6495ca1f293def3acc76.tar.gz |
Fix read_pofile handling of missing plurals
Diffstat (limited to 'babel')
-rw-r--r-- | babel/messages/pofile.py | 14 |
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: |