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

Conversation

samhocevar
Copy link
Contributor

@samhocevar samhocevar commented Feb 21, 2022

This patch prevents polib from creating illegal pofiles (that have #| msgctxt but not #| msgid).

Here is a simple way to witness the behaviour:

before.po

msgid ""
msgstr ""

#, fuzzy
#| msgctxt "oldcontext"
#| msgid ""
msgctxt "newcontext"
msgid ""
msgstr "After"

test.py

import polib
polib.pofile('before.po').save('after.po')

Result

By running test.py you can observe that the #| msgid "" line has disappeared. This makes the .po file invalid, and tools such as e.g. msgmerge will no longer be able to open it. For instance:

# cp after.po after.pot
# msgmerge after.po after.pot
after.po:7:8: syntax error
msgmerge: found 1 fatal error
#

This prevents polib from creating illegal pofiles (that have "#| msgctxt" but no "#| msgid").
@izimobil izimobil merged commit a67f372 into izimobil:master Mar 9, 2022
@izimobil
Copy link
Owner

izimobil commented Mar 9, 2022

Merged, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants