Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel/messages/pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ def _add_message(self) -> None:

def _finish_current_message(self) -> None:
if self.messages:
if not self.translations:
self.translations.append([0, _NormalizedString("")])
self._invalid_pofile("", self.offset, f"missing msgstr for msgid: '{self.messages[0].denormalize()}'")
self._add_message()

def _process_message_line(self, lineno, line, obsolete=False) -> None:
Expand Down
7 changes: 7 additions & 0 deletions tests/messages/test_pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,3 +1014,10 @@ def test_issue_1087():
"Language: \n"
''')
assert pofile.read_po(buf).locale is None

def test_issue_1134():
buf = StringIO('''msgid "this is an invalid po file"
msgstr "hello world"
msgid "msgid without str"''')
with pytest.raises(pofile.PoFileError):
pofile.read_po(buf, abort_invalid=True)