From 45cef2af6a71c58f8de2d57b678bd822414b405d Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Sun, 9 Feb 2025 15:19:51 +0100 Subject: [PATCH 1/2] Improve the help text of pygettext --- Lib/test/test_tools/test_i18n.py | 6 ++++++ Tools/i18n/pygettext.py | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py index 29c3423e234d20..edc3d544fbf2ae 100644 --- a/Lib/test/test_tools/test_i18n.py +++ b/Lib/test/test_tools/test_i18n.py @@ -407,6 +407,12 @@ def test_files_list(self): self.assertIn(f'msgid "{text2}"', data) self.assertNotIn(text3, data) + def test_help_text(self): + """Test that the help text is displayed.""" + res = assert_python_ok(self.script, '--help') + self.assertEqual(res.out, b'') + self.assertIn(b'pygettext -- Python equivalent of xgettext(1)', res.err) + def update_POT_snapshots(): for input_file in DATA_DIR.glob('*.py'): diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index d8a0e379ab82cb..1c7552cd359ce1 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -67,7 +67,8 @@ -k word --keyword=word Keywords to look for in addition to the default set, which are: - %(DEFAULTKEYWORDS)s + _, gettext, ngettext, pgettext, npgettext, dgettext, dngettext, + dpgettext, and dnpgettext. You can have multiple -k flags on the command line. @@ -171,7 +172,7 @@ def usage(code, msg=''): - print(__doc__ % globals(), file=sys.stderr) + print(__doc__, file=sys.stderr) if msg: print(msg, file=sys.stderr) sys.exit(code) From 2be45a24250d7d4745ec78dddf77640263f50a7d Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Sun, 9 Feb 2025 20:29:14 +0100 Subject: [PATCH 2/2] Add news entry --- .../Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst b/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst new file mode 100644 index 00000000000000..1903af78128ffc --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst @@ -0,0 +1 @@ +Fix the keyword entry in the help output of :program:`pygettext`.