#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019569091e34-bfd35898-7dd7-4912-a4fd-5ac3253807d6-000000%40eu-central-1.amazonses.com.