Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser-icu does not handle HTML tags #104

Closed
pboguslawski opened this issue Dec 29, 2022 · 1 comment
Closed

parser-icu does not handle HTML tags #104

pboguslawski opened this issue Dec 29, 2022 · 1 comment

Comments

@pboguslawski
Copy link

pboguslawski commented Dec 29, 2022

Using HTML tags in translations makes parser-icu throw

500

INVALID_TAG

SyntaxError: INVALID_TAG
    at Function.parse [as __parse] (/@fs/tmp/lib/node_modules/@formatjs/icu-messageformat-parser/lib/index.js:31:21)
    at new IntlMessageFormat (/@fs/tmp/lib/node_modules/intl-messageformat/lib/src/core.js:136:42)
    at Object.parse (/@fs/tmp/lib/node_modules/@sveltekit-i18n/parser-icu/dist/index.js:1:154)
    at O (/@fs/tmp/lib/node_modules/@sveltekit-i18n/base/dist/index.js:1:1261)
    at /@fs/tmp/lib/node_modules/@sveltekit-i18n/base/dist/index.js:1:4065
    at index.svelte:21:10
    at Object.$$render (/@fs/tmp/lib/node_modules/svelte/internal/index.mjs:1770:22)
    at Object.default (root.svelte:43:39)
    at eval (/src/routes/__layout.svelte:29:41)
    at Object.$$render (/@fs/tmp/lib/node_modules/svelte/internal/index.mjs:1770:22)

To repoduce: setup example as described on https://github.com/sveltekit-i18n/lib/tree/master/examples/parser-icu and change

"plural": "You have {value, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",

to

"plural": "<a href=\"https://example.com/\">You</a> have {value, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",

in src/lib/translations/en/content.json and change

<p>{$t('content.plural', { value: $number })}</p>

to

<p>{@html $t('content.plural', { value: $number })}</p>

in src/routes/index.svelte.

@pboguslawski
Copy link
Author

Works fine when quoted like this:

"plural": "'<a href=\"https://example.com/\">'You'</a>' have {value, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",

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

No branches or pull requests

1 participant