[Django] #29175: makemessages does parse ES6 template strings

81 views
Skip to first unread message

Django

unread,
Mar 1, 2018, 5:39:00 AM3/1/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
-----------------------------------------+------------------------
Reporter: tonnzor | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | 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 |
-----------------------------------------+------------------------
ECMAScript 6 introduced template strings, that are easy to use
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Template_literals

But Django 2.0.2 does not recognize it when it tries to extract
translations into PO file. It also gives you a warning in some cases.

Demo:

{{{
# main.js

let header = `${_("Header")}`;

const get_url = id => `/my_user/${id}/`;

let header_old = _("Header old");
}}}

Run:
{{{
./manage.py makemessages -d djangojs -a
}}}

PO file would contain only "Header old".

This is a synthetic example, you could see real-life file attached. It
would generate following warnings:

{{{
api.js:90: warning: unterminated string
api.js:139: warning: RegExp literal terminated too early
}}}

As far as I get, it ignores back-ticks and treats content as regular
expression here.

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

Django

unread,
Mar 1, 2018, 5:39:46 AM3/1/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
-------------------------------+--------------------------------------

Reporter: tonnzor | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
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 tonnzor):

* Attachment "api.js" added.

Sample ES6 file that raises a warning

Django

unread,
Mar 1, 2018, 5:41:22 AM3/1/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
-------------------------------------+-------------------------------------
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)
* type: Uncategorized => Bug
* component: Uncategorized => Internationalization


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

Django

unread,
Mar 5, 2018, 1:08:35 PM3/5/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
-------------------------------------+-------------------------------------
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):

Isn't this an [https://savannah.gnu.org/bugs/?50920 xgettext issue] rather
than something Django can solve?

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

Django

unread,
Mar 7, 2018, 3:56:35 PM3/7/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
--------------------------------------+------------------------------------

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:

Same as #29174, I even found the gettext bug report:
https://savannah.gnu.org/bugs/?50920

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

Django

unread,
Apr 16, 2018, 12:50:21 PM4/16/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
--------------------------------------+------------------------------------
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):

* Attachment "29174.diff" added.

Tentative doc patch

Django

unread,
Apr 16, 2018, 12:51:17 PM4/16/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

Draft patch attached for resolving both #29175 and #29174.

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

Django

unread,
Apr 16, 2018, 1:46:11 PM4/16/18
to django-...@googlegroups.com
#29175: makemessages does parse ES6 template strings
--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham):

That looks okay. I create a [https://github.com/django/django/pull/9880
PR]. One comment there.

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

Django

unread,
Apr 17, 2018, 9:19:19 PM4/17/18
to django-...@googlegroups.com
#29175: makemessages doesn't parse ES6 template strings

--------------------------------------+------------------------------------
Reporter: Artem Skoretskiy | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

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

Django

unread,
Apr 18, 2018, 8:30:13 AM4/18/18
to django-...@googlegroups.com
#29175: makemessages doesn't parse ES6 template strings
--------------------------------------+------------------------------------
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: 1 | 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/29175#comment:7>

Django

unread,
Apr 18, 2018, 8:35:55 AM4/18/18
to django-...@googlegroups.com
#29175: makemessages doesn't parse ES6 template strings
--------------------------------------+------------------------------------
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: 1 | 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/29175#comment:8>

Django

unread,
Apr 18, 2018, 8:36:23 AM4/18/18
to django-...@googlegroups.com
#29175: makemessages doesn't parse ES6 template strings
--------------------------------------+------------------------------------
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: 1 | 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/29175#comment:9>

Django

unread,
Apr 18, 2018, 9:04:33 AM4/18/18
to django-...@googlegroups.com
#29175: makemessages doesn't parse ES6 template strings
--------------------------------------+------------------------------------
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: 1 | 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/29175#comment:10>

Reply all
Reply to author
Forward
0 new messages