Skip to content

Commit 33834cb

Browse files
miss-islingtonStanFromIrelandtomasr8
authored
[3.12] gh-131852: Filter out POT-Creation-Date in msgfmt (GH-131880) (GH-132216)
(cherry picked from commit ad6a032) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
1 parent 81bc2cc commit 33834cb

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Lib/test/test_tools/msgfmt_data/general.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"",
4-
"Project-Id-Version: PACKAGE VERSION\nPOT-Creation-Date: 2024-10-26 18:06+0200\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <LL@li.org>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"
4+
"Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <LL@li.org>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"
55
],
66
[
77
"\n newlines \n",
-41 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:program:`msgfmt` no longer adds the ``POT-Creation-Date`` to generated ``.mo`` files
2+
for consistency with GNU ``msgfmt``.

Tools/i18n/msgfmt.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,19 @@ def make(filename, outfile):
148148
msgctxt = b''
149149
elif l.startswith('msgid') and not l.startswith('msgid_plural'):
150150
if section == STR:
151-
add(msgctxt, msgid, msgstr, fuzzy)
152-
msgctxt = None
153151
if not msgid:
152+
# Filter out POT-Creation-Date
153+
# See issue #131852
154+
msgstr = b''.join(line for line in msgstr.splitlines(True)
155+
if not line.startswith(b'POT-Creation-Date:'))
156+
154157
# See whether there is an encoding declaration
155158
p = HeaderParser()
156159
charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
157160
if charset:
158161
encoding = charset
162+
add(msgctxt, msgid, msgstr, fuzzy)
163+
msgctxt = None
159164
section = ID
160165
l = l[5:]
161166
msgid = msgstr = b''

0 commit comments

Comments
 (0)