globalizejs / globalizejs/globalize

Cannot escape pattern in curly braces with single quotes

Open
#837 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

Hello, thank you for this package.
Could you please check if this is a bug.
I am trying to escape a message pattern argument using single quotes. The argument is defined as index in curly braces.
The problem is I have no luck to obtain the message that contains the unchanged pattern.
Short code:
...
`Globalize.loadMessages({
en: {
escaped: "Escaped '{0}'"
}
});

Globalize.locale( "en" );

var escaped = Globalize.messageFormatter( "escaped" );

console.log( escaped() ); // here "Escaped {0}" is expected, but got "Cannot read property '0' of undefined"
`
...
Output with error:
return function(d) { return "Escaped '" + d["0"] + "'"; }
^

TypeError: Cannot read property '0' of undefined
at eval (eval at MessageFormat.compile (D:\skre\projects\JavaScript\Globalize\EscapeTest\node_modules\globalize\dist\globalize\message.js:1820:13), :3:44)

Thank you.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.