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.
* Attachment "api.js" added.
Sample ES6 file that raises a warning
* cc: Artem Skoretskiy (added)
* type: Uncategorized => Bug
* component: Uncategorized => Internationalization
--
Ticket URL: <https://code.djangoproject.com/ticket/29175#comment:1>
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>
* 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>
* Attachment "29174.diff" added.
Tentative doc patch
* has_patch: 0 => 1
Comment:
Draft patch attached for resolving both #29175 and #29174.
--
Ticket URL: <https://code.djangoproject.com/ticket/29175#comment:4>
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>
--
Ticket URL: <https://code.djangoproject.com/ticket/29175#comment:6>
* 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>
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>
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>
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>