]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-131852: Filter out POT-Creation-Date in msgfmt (GH-131880) (GH-132216)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Apr 2025 11:52:22 +0000 (13:52 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Apr 2025 11:52:22 +0000 (11:52 +0000)
(cherry picked from commit ad6a032cebf59d1668caa7e726aa5da72e1cbb5c)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Lib/test/test_tools/msgfmt_data/general.json
Lib/test/test_tools/msgfmt_data/general.mo
Misc/NEWS.d/next/Tools-Demos/2025-03-29-16-20-00.gh-issue-131852.afuefb.rst [new file with mode: 0644]
Tools/i18n/msgfmt.py

index 8ceb34cd17fb074ee7e0470e3c2a03b9811e96c5..0586113985a1122e6a5e6577b41e5dd2e88ddf12 100644 (file)
@@ -1,7 +1,7 @@
 [
     [
         "",
-        "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"
+        "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"
     ],
     [
         "\n newlines \n",
index 44b7363071a98bfe61eadc6adb0b434f1fd36125..ee905cbb3ec58db04c2f2fca5f67e15ce7a852c9 100644 (file)
Binary files a/Lib/test/test_tools/msgfmt_data/general.mo and b/Lib/test/test_tools/msgfmt_data/general.mo differ
diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-03-29-16-20-00.gh-issue-131852.afuefb.rst b/Misc/NEWS.d/next/Tools-Demos/2025-03-29-16-20-00.gh-issue-131852.afuefb.rst
new file mode 100644 (file)
index 0000000..470c1b0
--- /dev/null
@@ -0,0 +1,2 @@
+:program:`msgfmt` no longer adds the ``POT-Creation-Date`` to generated ``.mo`` files
+for consistency with GNU ``msgfmt``.
index c0da976979848ae06022ed887b318a4e93187cec..ecebf5d6a51ee87f4dddcc573fd84cf670b058d3 100755 (executable)
@@ -148,14 +148,19 @@ def make(filename, outfile):
             msgctxt = b''
         elif l.startswith('msgid') and not l.startswith('msgid_plural'):
             if section == STR:
-                add(msgctxt, msgid, msgstr, fuzzy)
-                msgctxt = None
                 if not msgid:
+                    # Filter out POT-Creation-Date
+                    # See issue #131852
+                    msgstr = b''.join(line for line in msgstr.splitlines(True)
+                                      if not line.startswith(b'POT-Creation-Date:'))
+
                     # See whether there is an encoding declaration
                     p = HeaderParser()
                     charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
                     if charset:
                         encoding = charset
+                add(msgctxt, msgid, msgstr, fuzzy)
+                msgctxt = None
             section = ID
             l = l[5:]
             msgid = msgstr = b''