[Django] #29174: makemessages does not find translations in Python 3.6 formatted string literals

7 views
Skip to first unread message

Django

unread,
Mar 1, 2018, 5:28:53 AM3/1/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
------------------------------------------------+------------------------
Reporter: tonnzor | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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".

--
Ticket URL: <https://code.djangoproject.com/ticket/29174>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 1, 2018, 5:41:56 AM3/1/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
-------------------------------------+-------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.0
Internationalization |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Artem Skoretskiy):

* cc: Artem Skoretskiy (added)


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

Django

unread,
Mar 5, 2018, 1:09:39 PM3/5/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
-------------------------------------+-------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Bug | Status: new

Component: | Version: 2.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

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

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

Django

unread,
Mar 7, 2018, 3:52:31 PM3/7/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
--------------------------------------+------------------------------------

Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Claude Paroz):

* component: Internationalization => Documentation
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

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

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

Django

unread,
Apr 18, 2018, 8:30:11 AM4/18/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson <carlton.gibson@…>):

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


Comment:

In [changeset:"c3437f734d03d93f798151f712064394652cabed" c3437f73]:
{{{
#!CommitTicketReference repository=""
revision="c3437f734d03d93f798151f712064394652cabed"
Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript template
strings can't be translated.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29174#comment:4>

Django

unread,
Apr 18, 2018, 8:35:55 AM4/18/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"8b4798c8d31b3cd9faab4caf11fca000b07f0181" 8b4798c]:
{{{
#!CommitTicketReference repository=""
revision="8b4798c8d31b3cd9faab4caf11fca000b07f0181"
[1.11.x] Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript


template strings can't be translated.

Backport of c3437f734d03d93f798151f712064394652cabed from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29174#comment:5>

Django

unread,
Apr 18, 2018, 8:36:24 AM4/18/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"0d2ec8db483a900c27b8fada30688ef8f25cecfa" 0d2ec8d]:
{{{
#!CommitTicketReference repository=""
revision="0d2ec8db483a900c27b8fada30688ef8f25cecfa"
[2.0.x] Fixed #29174, #29175 -- Doc'd that f-strings and JavaScript


template strings can't be translated.

Backport of c3437f734d03d93f798151f712064394652cabed from master
}}}

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

Django

unread,
Apr 18, 2018, 9:04:34 AM4/18/18
to django-...@googlegroups.com
#29174: makemessages does not find translations in Python 3.6 formatted string
literals
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"a5d1fe59c59fa716918b6cec5e8ab747720b74fc" a5d1fe5]:
{{{
#!CommitTicketReference repository=""
revision="a5d1fe59c59fa716918b6cec5e8ab747720b74fc"
Revert "[1.11.x] Fixed #29174, #29175 -- Doc'd that f-strings and


JavaScript template strings can't be translated."

This reverts commit 8b4798c8d31b3cd9faab4caf11fca000b07f0181.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29174#comment:7>

Reply all
Reply to author
Forward
0 new messages