[issue36310] pygettext3.7 Does Not Recognize gettext Calls Within fstrings

2019-05-09 Thread Allie Fitter


Allie Fitter  added the comment:

Just as context, my use case for this is interpolating translated strings into 
HTML.

html = f'''\
{_("Some Title")}
{_("Some longer text")}
'''

--

___
Python tracker 
<https://bugs.python.org/issue36310>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36310] pygettext3.7 Does Not Recognize gettext Calls Within fstrings

2019-03-15 Thread Allie Fitter


New submission from Allie Fitter :

pygettext can't see gettext functions calls when they're inside of an fstring:

foo.py

from gettext import gettext as _

foo = f'{_("foo bar baz")}'

Running `pygettext3.7 -kgt -d message -D -v -o locales/message.pot foo.py` 
results in:

locale/message.pot
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR , YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-03-15 21:02-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \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"

Change foo.py to:

from gettext import gettext as _

foo = f'' + _("foo bar baz") + ''


Results in:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR , YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-03-15 21:05-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \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"


#: foo.py:3
msgid "foo bar baz"
msgstr ""


Running on Ubuntu 18.04.

--
components: Demos and Tools
messages: 338049
nosy: Allie Fitter
priority: normal
severity: normal
status: open
title: pygettext3.7 Does Not Recognize gettext Calls Within fstrings
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36310>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com