10000 gh-126700: pygettext: Support more gettext functions by tomasr8 · Pull Request #126912 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-126700: pygettext: Support more gettext functions #126912

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

Merged
merged 14 commits into from
Nov 22, 2024
Prev Previous commit
Next Next commit
Only extract when __enclosure_count is 0
  • Loading branch information
tomasr8 committed Nov 18, 2024
commit d6fd789c15a575b46b104a0492b67304f3d66655
26 changes: 13 additions & 13 deletions Lib/test/test_tools/i18n_data/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,57 @@ msgid ""
" multiline!\n"
msgstr ""

#: messages.py:40 messages.py:83 messages.py:84 messages.py:87 messages.py:88
#: messages.py:93
#: messages.py:43 messages.py:86 messages.py:87 messages.py:90 messages.py:91
#: messages.py:96
msgid "foo"
msgid_plural "foos"
msgstr[0] ""
msgstr[1] ""

#: messages.py:41
#: messages.py:44
msgid "something"
msgstr ""

#: messages.py:44
#: messages.py:47
msgid "Hello, {}!"
msgstr ""

#: messages.py:48
#: messages.py:51
msgid "1"
msgstr ""

#: messages.py:48
#: messages.py:51
msgid "2"
msgstr ""

#: messages.py:49 messages.py:50
#: messages.py:52 messages.py:53
msgid "A"
msgstr ""

#: messages.py:49 messages.py:50
#: messages.py:52 messages.py:53
msgid "B"
msgstr ""

#: messages.py:51
#: messages.py:54
msgid "set"
msgstr ""

#: messages.py:57
#: messages.py:60
msgid "nested string"
msgstr ""

#: messages.py:62
#: messages.py:65
msgid "baz"
msgstr ""

#: messages.py:85 messages.py:86 messages.py:89 messages.py:90
#: messages.py:88 messages.py:89 messages.py:92 messages.py:93
msgctxt "context"
msgid "foo"
msgid_plural "foos"
msgstr[0] ""
msgstr[1] ""

#: messages.py:94
#: messages.py:97
msgid "domain foo"
msgstr ""

3 changes: 3 additions & 0 deletions Lib/test/test_tools/i18n_data/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
_(None)
_(1)
_(False)
_(("invalid"))
_(["invalid"])
_({"invalid"})

# pygettext does not allow keyword arguments, but both xgettext and pybabel do
_(x="kwargs work!")
Expand Down
2 changes: 1 addition & 1 deletion Tools/i18n/pygettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def __openseen(self, ttype, tstring, lineno):
self.warn_unexpected_token(tstring)
self.__enclosurecount = 0
self.__state = self.__waiting
elif expect_string_literal:
elif expect_string_literal and self.__enclosurecount == 0:
if ttype == tokenize.STRING and is_literal_string(tstring):
self.__data[arg_type] += safe_eval(tstring)
elif ttype not in (tokenize.COMMENT, tokenize.INDENT, tokenize.DEDENT,
Expand Down
Loading
0