This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients mdk, vstinner
Date 2019-03-08.13:58:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552053499.48.0.311631388539.issue36239@roundup.psfhosted.org>
In-reply-to
Content
When a translation .po file contains a comment in headers, it's kept when compiled as .mo by msgfmt.

Example with test.po:
---
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Plural-Forms:  nplurals=2; plural=(n != 1);\n"
"#-#-#-#-#  plo.po (PACKAGE VERSION)  #-#-#-#-#\n"
---

Compile it with "msgfmt". Parse the output file messages.mo using test.py script:
---
import gettext, pprint
with open("messages.mo", "rb") as fp:
    t = gettext.GNUTranslations()
    t._parse(fp)
    pprint.pprint(t._info)
---

Output on Python 3.7.2:
---
{'content-type': 'text/plain; charset=UTF-8',
 'plural-forms': 'nplurals=2; plural=(n != 1);\n'
                 '#-#-#-#-#  plo.po (PACKAGE VERSION)  #-#-#-#-#'}
---

Output of Fedora Python 2.7.15 which contains a fix:
---
{'content-type': 'text/plain; charset=UTF-8',
 'plural-forms': 'nplurals=2; plural=(n != 1);'}
---

I'm not sure that keeping the comment as part of plural forms is correct. Comments should not be ignored?

I made my test on Fedora 29: msgfmt 0.19.8.1, Python 3.7.2.

Links:

* https://bugs.python.org/issue1448060#msg27754
* https://bugs.python.org/issue1475523
* https://bugzilla.redhat.com/show_bug.cgi?id=252136

Fedora has a patch since 2007 to ignore comments:
https://src.fedoraproject.org/rpms/python2/blob/master/f/python-2.5.1-plural-fix.patch

I can easily convert the patch to a PR, maybe with a test. The question is more if the fix is correct or not.
History
Date User Action Args
2019-03-08 13:58:19vstinnersetrecipients: + vstinner, mdk
2019-03-08 13:58:19vstinnersetmessageid: <1552053499.48.0.311631388539.issue36239@roundup.psfhosted.org>
2019-03-08 13:58:19vstinnerlinkissue36239 messages
2019-03-08 13:58:19vstinnercreate