[Django] #35993: Replace outdated information on gettext f-string support

32 views
Skip to first unread message

Django

unread,
Dec 10, 2024, 4:51:05 AM12/10/24
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
---------------------+-----------------------------------------
Reporter: Tom | Type: Bug
Status: new | Component: Documentation
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------+-----------------------------------------
{{{ gettext }}} 0.23+ supports the f-string syntax according to their
[https://savannah.gnu.org/bugs/?61596 bugtracker]. Testing in practice
confirms this. The current version of the documentation says that the
syntax is not supported. The associated Pull Request (to be created)
changes this to inform the reader that they can use f-string syntax with
{{{ gettext }}} 0.23+.
--
Ticket URL: <https://code.djangoproject.com/ticket/35993>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 10, 2024, 4:56:45 AM12/10/24
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+--------------------------------------
Reporter: Athena | Owner: (none)
Type: Bug | Status: new
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Athena):

* has_patch: 0 => 1


Old description:

> {{{ gettext }}} 0.23+ supports the f-string syntax according to their
> [https://savannah.gnu.org/bugs/?61596 bugtracker]. Testing in practice
> confirms this. The current version of the documentation says that the
> syntax is not supported. The associated Pull Request (to be created)
> changes this to inform the reader that they can use f-string syntax with
> {{{ gettext }}} 0.23+.

New description:

{{{ gettext }}} 0.23+ supports the f-string syntax according to their
[https://savannah.gnu.org/bugs/?61596 bugtracker]. Testing in practice
confirms this. The current version of the documentation says that the
syntax is not supported. The associated
[https://github.com/django/django/pull/18910 Pull Request] changes this to
inform the reader that they can use f-string syntax with {{{ gettext }}}
0.23+.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:1>

Django

unread,
Dec 10, 2024, 6:05:45 AM12/10/24
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+------------------------------------
Reporter: Athena | Owner: Athena
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Sarah Boyce):

* cc: Claude Paroz (added)
* owner: (none) => Athena
* stage: Unreviewed => Accepted
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:2>

Django

unread,
Dec 16, 2024, 4:09:26 AM12/16/24
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+------------------------------------
Reporter: Athena | Owner: Athena
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:3>

Django

unread,
Mar 5, 2025, 8:02:05 PM3/5/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+------------------------------------
Reporter: Athena | Owner: Athena
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Ahmed Nassar):

I'd love to contribute to this issue and help improve the patch. Could you
provide more details on what specific improvements are needed?
Looking forward to contributing.
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:4>

Django

unread,
Mar 5, 2025, 8:19:26 PM3/5/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+------------------------------------
Reporter: Athena | Owner: Athena
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Ahmed Nassar):

Hi everyone,

After reviewing the current state of PR #18910 and doing some additional
testing regarding gettext f-string support, I'd like to contribute some
important findings:

1. There seems to be a misunderstanding about the actual f-string support
in gettext 0.23+. The NEWS entry stating "Python: xgettext now recognizes
the f-string syntax" actually indicates that newer versions of xgettext no
longer extract f-strings into .po files (contrary to version 0.21.1 which
did).

2. Important technical limitations:
- F-string expressions are evaluated before Python's gettext
implementation can process them
- Django uses Python's gettext implementation rather than the system
gettext
- This means we cannot use f-strings directly with gettext in the way
many might expect

3. Suggested documentation updates should:
- Clarify these limitations explicitly
- Provide correct usage examples
- Explain why certain patterns don't work (e.g., `_(f"Welcome
{staff}")`)
- Recommend proper alternatives using .format() or % formatting

I can help update the PR to reflect these findings and provide clearer
documentation about what is and isn't supported. Would this approach be
helpful?
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:5>

Django

unread,
Mar 5, 2025, 8:25:13 PM3/5/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+------------------------------------
Reporter: Athena | Owner: Athena
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Ahmed Nassar):

Hello,

I've reviewed PR #18910 and identified some critical technical aspects
regarding gettext f-string support that need to be addressed in the
documentation:

1. There's a key misunderstanding about gettext 0.23+ behavior:
- The change actually prevents f-string extraction, rather than adding
support
- This differs from 0.21.1 which extracted f-strings into .po files

2. Important technical limitations:
- F-string expressions evaluate before gettext processing occurs
- Django uses Python's gettext implementation, not system gettext

I'd be happy to help improve the patch by:
- Adding clear documentation about these limitations
- Providing correct usage examples
- Including proper alternatives using .format() or % formatting
- Explaining why patterns like _(f"Welcome {staff}") don't work

Would this approach align with what's needed for this ticket? I can submit
an updated PR addressing these points.

Best regards
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:6>

Django

unread,
Mar 12, 2025, 12:36:07 PM3/12/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Abigail Afi Gbadago):

* owner: Athena => Ahmed Nassar

Comment:

Assigning to Ahmed Nassar due to the inactivity of the owner.
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:7>

Django

unread,
Apr 1, 2025, 12:54:58 AM4/1/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Comment (by Ahmed Nassar):

Replying to [comment:7 Abigail Afi Gbadago]:
> Assigning to Ahmed Nassar due to the inactivity of the owner.
I'd like to help move this forward. Based on the discoveries about gettext
f-string support limitations, would you prefer to continue work on current
PR, or create a new PR addressing the findings in the comments?
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:8>

Django

unread,
Apr 5, 2025, 7:43:28 PM4/5/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Comment (by Ahmed Nassar):

I've submitted a pull request that addresses this ticket:
https://github.com/django/django/pull/19348
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:9>

Django

unread,
Apr 5, 2025, 7:50:42 PM4/5/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Ahmed Nassar):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:10>

Django

unread,
Apr 7, 2025, 7:26:27 AM4/7/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:11>

Django

unread,
Apr 8, 2025, 1:29:36 AM4/8/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------+----------------------------------------
Reporter: Athena | Owner: Ahmed Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Ahmed Nassar):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:12>

Django

unread,
Apr 14, 2025, 3:20:14 AM4/14/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------------+-------------------------------------
Reporter: Athena | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:13>

Django

unread,
Apr 15, 2025, 4:02:36 AM4/15/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------------+-------------------------------------
Reporter: Athena | Owner: Ahmed
| Nassar
Type: Bug | Status: closed
Component: Documentation | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"2c2f09055579cc6068cae6c6fd3135011d6df4f1" 2c2f0905]:
{{{#!CommitTicketReference repository=""
revision="2c2f09055579cc6068cae6c6fd3135011d6df4f1"
Fixed #35993 -- Documented gettext f-string support limitations.

Thank you to Claude Paroz and Athena Wolfskämpf for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:14>

Django

unread,
Apr 15, 2025, 4:04:32 AM4/15/25
to django-...@googlegroups.com
#35993: Replace outdated information on gettext f-string support
-------------------------------------+-------------------------------------
Reporter: Athena | Owner: Ahmed
| Nassar
Type: Bug | Status: closed
Component: Documentation | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"aa2c7659d5d95fde3072903b7bd70d16f7d6e045" aa2c7659]:
{{{#!CommitTicketReference repository=""
revision="aa2c7659d5d95fde3072903b7bd70d16f7d6e045"
[5.2.x] Fixed #35993 -- Documented gettext f-string support limitations.

Thank you to Claude Paroz and Athena Wolfskämpf for the review.

Backport of 2c2f09055579cc6068cae6c6fd3135011d6df4f1 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35993#comment:15>
Reply all
Reply to author
Forward
0 new messages