question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

intl-messageformat throws error when HTML included in message

See original GitHub issue

With the latest release and move to the latest intl-messageformat messages that include variables and HTML tags have started to throw errors.

This has been caused by a new option and functionality in intl-messageformat, ignoreTag that is defaulted to false and not exposed or set by svelte-i18n.

Logs SyntaxError: Expected “#”, “'”, “\n”, “{”, argumentElement, double apostrophes, end of input, or tagElement but “<” found.

To Reproduce I will open a PR and reference in comments.

Expected behavior Messages with variables and HTML continue to behave as they have done and b rendered correctly.

Stacktraces If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread’s readability:

Stack trace

SyntaxError: Expected “#”, “'”, “\n”, “{”, argumentElement, double apostrophes, end of input, or tagElement but “<” found. at peg$buildStructuredError (svelte-i18n/node_modules/intl-messageformat-parser/src/parser.js:401:16) at Object.peg$parse [as pegParse] (svelte-i18n/node_modules/intl-messageformat-parser/src/parser.js:3109:15) at Function.parse [as __parse] (svelte-i18n/node_modules/intl-messageformat-parser/index.js:11:24) at new IntlMessageFormat (svelte-i18n/node_modules/intl-messageformat/src/core.js:138:42) at svelte-i18n/src/runtime/includes/formatters.ts:94:5 at Object.memoizedFn (svelte-i18n/src/runtime/includes/memoize.ts:13:31) at Object.<anonymous> (svelte-i18n/test/runtime/includes/formatters.test.ts:201:7) at Object.asyncJestTest (svelte-i18n/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37) at svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:45:12 at new Promise (<anonymous>) at mapper (svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:28:19) at svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:75:41 at processTicksAndRejections (internal/process/task_queues.js:93:5)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
superafromancommented, Jan 22, 2021

Hey @cupcakearmy, you can work around not having this option by escaping your HTML tags, e.g.

{
  someGreatLookupKey: `'<p>'Your account will be connected with '<strong>'{name}'</strong></p>'`
}
1reaction
kaisermanncommented, Feb 11, 2021

Fixed in 3.3.2 🎉 thanks @superafroman!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intl MessageFormat | Format.JS
Intl MessageFormat. Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.
Read more >
intl-messageformat: String formatter · Issue #1648 - GitHub
An obvious one might be a string that is not HTML but documents HTML so it might contain HTML strings in it. The...
Read more >
Top 5 intl-messageformat Code Examples - Snyk
To help you get started, we've selected a few intl-messageformat examples, ... throw new Error( 'Locale data provided to IntlRelativeFormat is missing a...
Read more >
Extending react-intl with your own markup - Keypup
In this section we'll see how to use react-intl to translate messages and how to dynamically format these messages.
Read more >
Message Format Syntax - Vue I18n
Vue I18n can use message format syntax to localize the messages to ... use HTML interpolation on trusted content and never on user-provided...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found