#29175 closed Cleanup/optimization (fixed)
makemessages doesn't parse ES6 template strings
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.
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