Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Fails on ES6 backtick quotes #5

Open
AArnott opened this issue Aug 1, 2016 · 2 comments
Open

Fails on ES6 backtick quotes #5

AArnott opened this issue Aug 1, 2016 · 2 comments
Assignees
Milestone

Comments

@AArnott
Copy link
Member

AArnott commented Aug 1, 2016

We have this code that vscode-nls-dev rewrites:

public static failedToEnumerateFilesInDir(path: string, errCode: string, errMessage: string): string {
    return localize(
        {
            key: 'Failed.To.Enumerate.Files.In.Dir',
            comment:
            [
                'Error message when failed to enumerate files in a directory.'
            ]
        },
        `Failed to enumerate files in directory '{0}'. Error code={1}, Error message={2}`,
        path,
        errCode,
        errMessage
    );
}

When targeting ES5, all is well. But once we target ES6, the backtick as a quote character is preserved:

static failedToEnumerateFilesInDir(path, errCode, errMessage) {
    return localize({
        key: 'Failed.To.Enumerate.Files.In.Dir',
        comment: [
            'Error message when failed to enumerate files in a directory.'
        ]
    }, `Failed to enumerate files in directory '{0}'. Error code={1}, Error message={2}`, path, errCode, errMessage);
}

This causes vscode-nls-dev to fail during build with this error:

libraryResourceStrings.js(661,11): second argument of a localize call must be a string literal.

For now we workaround it by changing our own use of backtick to single quotes. But that requires much more escaping in our English strings because we use single-quotes inside the localizable string.

Please enable use of backticks.

@seanzer
Copy link

seanzer commented Oct 10, 2017

+1

@seanzer
Copy link

seanzer commented Oct 10, 2017

I think another problem is that if I escape the new lines like:

"line one\
line two\
line three"

the \ gets escaped in the output, which means I have to strip them before I render it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants