Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure empty previous values for msgid and msgstr are properly saved. #121

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion polib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def __unicode__(self, wrapwidth=78):
prefix = "#| "
for f in fields:
val = getattr(self, f)
if val:
if val is not None:
ret += self._str_field(f, prefix, "", val, wrapwidth)

ret.append(_BaseEntry.__unicode__(self, wrapwidth))
Expand Down
7 changes: 7 additions & 0 deletions tests/test_previous_msgid.po
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ msgstr ""
#| msgid "Partition table entries are not in disk order2\n"
msgid "The new msgid2"
msgstr ""


#| msgctxt "Some other message context"
#| msgid ""
msgctxt "The new msgctxt3"
msgid "The new msgid3"
msgstr ""
17 changes: 17 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ def test_previous_msgid_2(self):
expected
)

def test_previous_msgid_3(self):
"""
Test saving empty previous msgid.
"""
po = polib.pofile('tests/test_previous_msgid.po')
fd, tmpfile = tempfile.mkstemp()
os.close(fd)
po.save(tmpfile)
po = polib.pofile(tmpfile)
os.remove(tmpfile)

expected = ""
self.assertEqual(
po[2].previous_msgid,
expected
)

def test_previous_msgctxt_1(self):
"""
Test previous msgctxt multiline.
Expand Down