#29175 closed Cleanup/optimization (fixed)
makemessages doesn't parse ES6 template strings
Reported by: | Artem Skoretskiy | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Artem Skoretskiy | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (2)
Change History (12)
by , 7 years ago
comment:1 by , 7 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Internationalization |
Type: | Uncategorized → Bug |
comment:3 by , 7 years ago
Component: | Internationalization → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Same as #29174, I even found the gettext bug report: https://savannah.gnu.org/bugs/?50920
comment:4 by , 7 years ago
Has patch: | set |
---|
comment:6 by , 7 years ago
Summary: | makemessages does parse ES6 template strings → makemessages doesn't parse ES6 template strings |
---|
Sample ES6 file that raises a warning