#31341 closed Cleanup/optimization (fixed)
Document minimal gettext version for ES6 template strings support
Reported by: | Cédric Eberhardt | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 3.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Hello,
Before I start, it's different than the #29175 issue.
The template strings are parsed, but partially.
For instance, in this code, "Home" is never discovered.
function create_fragment$4(ctx) { return { c() { div2.textContent = `${window.gettext("Customized Champagne")}`; attr(a0, "aria-label", a0_aria_label_value = window.gettext("Home"));
If I remove the textContent line, then "Home" is found.
I've also found other examples where when I remove a previous template string line, the next gettext (not necessarily within a template string) is discovered again.
Thanks.
Change History (8)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
The output from prepare_js_for_gettext
is the same as the code above.
Does it means that it's a problem from xgettext? (found on makemessages.py)
comment:3 by , 5 years ago
Based on c3437f734d03d93f798151f712064394652cabed which links to the gettext bug tracker I'm fairly confident this is a duplicate of #29175 .
From this comment.
So a template string inside any code block, {}, seems to cause xgettext to skip the rest of the file during parsing without warning or error.
That's exactly what you are experiencing here since removing the textContent
line allows following parsing to take place.
Looks like it was fixed in 2.0+ though so maybe we should re-purpose this ticket as a documentation adjustment? Could you try downloading the latest gettext
and see if it helps anyhow?
comment:4 by , 5 years ago
Thanks for the info. You're right. I tried with xgettext 0.20.1 (from Homebrew on macOS) and, as expected (and documented :P ), it doesn't work properly. Apparently there is a bug fix for xgettext from last summer, I'll try it.
comment:5 by , 5 years ago
Component: | Uncategorized → Internationalization |
---|---|
Easy pickings: | set |
Summary: | makemessages doesn't parse correctly/completely ES6 template strings → Document minimal gettext version for ES6 template strings support |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
I wonder if it's because our current JS lexer gets confused by that string.