Skip to content

gh-130197: pygettext: Fix and test the --exclude-file option #131381

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Lib/test/test_tools/i18n_data/exclude_file.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-01-01 00:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


msgid "excluded"
msgstr ""

msgid "multiline\nexcluded"
msgstr ""

msgid "singular excluded"
msgid_plural "plural excluded"
msgstr[0] ""
msgstr[1] ""

msgctxt "context"
msgid "context excluded"
msgstr ""

msgctxt "context"
msgid "context singular excluded"
msgid_plural "context plural excluded"
msgstr[0] ""
msgstr[1] ""

21 changes: 21 additions & 0 deletions Lib/test/test_tools/i18n_data/excluded.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-01-01 00:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#: excluded.py:4
msgid "foo"
msgstr ""

14 changes: 14 additions & 0 deletions Lib/test/test_tools/i18n_data/excluded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from gettext import gettext as _, ngettext, npgettext, pgettext


_('foo')

_('excluded')

_('multiline\nexcluded')

ngettext('singular excluded', 'plural excluded', 2)

pgettext('context', 'context excluded')

npgettext('context', 'context singular excluded', 'context plural excluded', 2)
103 changes: 103 additions & 0 deletions Lib/test/test_tools/i18n_data/general.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[
{
"msgctxt": null,
"msgid": "",
"msgid_plural": null,
"msgstr": "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"
},
{
"msgctxt": null,
"msgid": "foo",
"msgid_plural": null,
"msgstr": "bar"
},
{
"msgctxt": null,
"msgid": "Escape sequences \" \n \t",
"msgid_plural": null,
"msgstr": ""
},
{
"msgctxt": null,
"msgid": "Python",
"msgid_plural": null,
"msgstr": "Python"
},
{
"msgctxt": null,
"msgid": "Python (2)",
"msgid_plural": null,
"msgstr": "Python (2)"
},
{
"msgctxt": null,
"msgid": "αβ",
"msgid_plural": null,
"msgstr": "αβ"
},
{
"msgctxt": null,
"msgid": "barbaz",
"msgid_plural": null,
"msgstr": "quxxyz"
},
{
"msgctxt": null,
"msgid": "xyz",
"msgid_plural": null,
"msgstr": ""
},
{
"msgctxt": "context",
"msgid": "foo",
"msgid_plural": null,
"msgstr": "bar"
},
{
"msgctxt": "xyz",
"msgid": "foo",
"msgid_plural": null,
"msgstr": "bar"
},
{
"msgctxt": null,
"msgid": "One email sent.",
"msgid_plural": "%d emails sent.",
"msgstr": [
"One email sent.",
"%d emails sent."
]
},
{
"msgctxt": null,
"msgid": "One message sent.",
"msgid_plural": "%d messages sent.",
"msgstr": [
"%d message sent."
]
},
{
"msgctxt": "abc",
"msgid": "One email sent.",
"msgid_plural": "%d emails sent.",
"msgstr": [
"One email sent.",
"%d emails sent."
]
},
{
"msgctxt": null,
"msgid": "qux",
"msgid_plural": "quxs",
"msgstr": [
"abc",
"xyz"
]
},
{
"msgctxt": null,
"msgid": "baz",
"msgid_plural": null,
"msgstr": ""
}
]
85 changes: 85 additions & 0 deletions Lib/test/test_tools/i18n_data/general.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-10-26 18:06+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "foo"
msgstr "bar"

# Selected escape sequences are allowed
msgid "Escape sequences \" \n \t"
msgstr ""

# Octal escape sequences are allowed
msgid "\120\171\164\150\157\156"
msgstr "Python"

# Hex escape sequences are allowed
msgid "\x50\x79\x74\x68\x6f\x6e (2)"
msgstr "Python (2)"

# non-ascii
msgid "αβ"
msgstr "αβ"

# Empty lines are ignored
msgid ""
"bar"

"baz"
msgstr ""
"qux"

"xyz"

# Keyword line does not need to contain a string
msgid
"xyz"
msgstr ""

# comment
# comment

msgctxt "context"
msgid "foo"
msgstr "bar"

msgctxt "xyz"
msgid "foo"
msgstr "bar"

msgid "One email sent."
msgid_plural "%d emails sent."
msgstr[0] "One email sent."
msgstr[1] "%d emails sent."

# Each message can have a different number of msgstr[N]
msgid "One message sent."
msgid_plural "%d messages sent."
msgstr[0] "%d message sent."

msgctxt "abc"
msgid "One email sent."
msgid_plural "%d emails sent."
msgstr[0] "One email sent."
msgstr[1] "%d emails sent."

msgid "qux"
msgid_plural "quxs"
msgstr[0] "a"
"b"
"c"
msgstr[1] "x"
"y"
"z"

msgid "baz"
msgstr ""

# trailing comments are allowed
Loading
Loading