globalizejs / globalizejs/globalize
Cannot escape pattern in curly braces with single quotes
- 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
Assessment
This issue has not been assessed yet.