Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#29174 closed Cleanup/optimization (fixed)

makemessages does not find translations in Python 3.6 formatted string literals

Reported by: Artem Skoretskiy Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords:
Cc: Artem Skoretskiy Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Python 3.6 introduced formatted string literals, that are easy to use https://docs.python.org/3/reference/lexical_analysis.html#f-strings

But Django 2.0.2 does not recognize it when it tries to extract translations into PO file.

Demo:

# views.py
from django.utils.translation import ugettext_lazy as _

header = f'{_("Header")}'
header_old = '{}'.format(_("Header old"))

Run:

./manage.py makemessages -a

PO file would contain only "Header old".

Change History (7)

comment:1 by Artem Skoretskiy, 7 years ago

Cc: Artem Skoretskiy added

comment:2 by Tim Graham, 7 years ago

I don't have much expertise about translations but is this a Python or xgettext issue rather than something Django can solve?

comment:3 by Claude Paroz, 7 years ago

Component: InternationalizationDocumentation
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Yes, I guess the best we can do for now is documenting that current gettext limitation.

comment:4 by Carlton Gibson <carlton.gibson@…>, 7 years ago

Resolution: fixed
Status: newclosed

In c3437f73:

Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript template strings can't be translated.

comment:5 by Carlton Gibson <carlton.gibson@…>, 7 years ago

In 8b4798c:

[1.11.x] Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript template strings can't be translated.

Backport of c3437f734d03d93f798151f712064394652cabed from master

comment:6 by Carlton Gibson <carlton.gibson@…>, 7 years ago

In 0d2ec8d:

[2.0.x] Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript template strings can't be translated.

Backport of c3437f734d03d93f798151f712064394652cabed from master

comment:7 by Carlton Gibson <carlton.gibson@…>, 7 years ago

In a5d1fe5:

Revert "[1.11.x] Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript template strings can't be translated."

This reverts commit 8b4798c8d31b3cd9faab4caf11fca000b07f0181.

Note: See TracTickets for help on using tickets.
Back to Top