Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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 Simon Charette, 5 years ago

I wonder if it's because our current JS lexer gets confused by that string.

comment:2 by Cédric Eberhardt, 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 Simon Charette, 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?

From the changelog of 2.0 released May 2019

  • JavaScript:

xgettext now parses template literals correctly.

Last edited 5 years ago by Simon Charette (previous) (diff)

comment:4 by Cédric Eberhardt, 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 Claude Paroz, 5 years ago

Component: UncategorizedInternationalization
Easy pickings: set
Summary: makemessages doesn't parse correctly/completely ES6 template stringsDocument minimal gettext version for ES6 template strings support
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:6 by Claude Paroz, 5 years ago

Has patch: set

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 2f53d324:

Fixed #31341 -- Doc'd minimal gettext version with ES6 template strings support.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In e3069f66:

[3.0.x] Fixed #31341 -- Doc'd minimal gettext version with ES6 template strings support.

Backport of 2f53d324debee680658aed7f22f1aaf81385b1f2 from master

Note: See TracTickets for help on using tickets.
Back to Top