You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Svelte 5, when svelte-i18n translations ($_() or $json()) are used along with {@html } then it fallbacks to default language.
I wonder if I am doing something that should work or If I misunderstood how to use Svelte and svelte-i18n.
Screenshot to illustrate
Fallbacks to default (french)
{#each$json('philosophy.paragraphs') asparagraph}
<p>{@htmlparagraph}</p>
{/each}
<p>{@html$_('singular.html')}</p>
<hr/>
Does not fallback
{#each$json('philosophy.paragraphs') asparagraph}
<p>{paragraph}</p>
{/each}
<p>{$_('singular.html')}</p>
Default translation file sample `fr.json` :
{
"page": {
"title": "🇫🇷 svelte-i18n avec $json() et {@html}"
},
"philosophy": {
"title": "🇫🇷 Notre philosophie",
"paragraphs": [
"🇫🇷 Français Foo <strong>Bar</strong>",
"🇫🇷 Baz <strong>Polop ! </strong>"
]
},
"singular.html":"🇫🇷 Phrase seule avec des <strong>éléments HTML</strong>."
}
Translation file sample `en.json` :
{
"page": {
"title": "🇬🇧 svelte-i18n with $json() and {@html}"
},
"philosophy": {
"title": "🇬🇧Our philosophy",
"paragraphs": [
"🇬🇧 English Foo <strong>Bar</strong>",
"🇬🇧 Baz <strong>Polop ! </strong>"
]
},
"singular.html":"🇬🇧 Singular sentence with <strong>HTML elements</strong>."
}
Logs
Browser logs
+page.svelte:47 [svelte] hydration_html_changed The value of an `{@html ...}` block near src/routes/+page.svelte:52:1 changed between server and client renders. The client value will be ignored in favour of the server value
In this application default language is french. It will fallback to french by default.
Expected behavior
When your main language is english, the paragraphs below should be in english... But, they fallback to default language : french.
Stacktraces
Stack trace : "hydration_html_changed"
+page.svelte:47 [svelte] hydration_html_changed The value of an `{@html ...}` block near src/routes/+page.svelte:52:1 changed between server and client renders. The client value will be ignored in favour of the server value
Your browser and the version: Brave [Version 1.71.123 Chromium: 130.0.6723.116 (Official Build) (arm64]
Your operating system: MacOS Sequoia 15.0 (24A335)
svelte-i18n version : 4.0.1
Whether your project uses Webpack or Rollup : Vite
Svelte version : 5.2.0
The text was updated successfully, but these errors were encountered:
marc-bouvier
changed the title
hydration_html_changed when using $json() and {@html} in svelte 5
Svelte 5 : hydration_html_changed when using $_() or $json() and {@html}
Nov 15, 2024
marc-bouvier
changed the title
Svelte 5 : hydration_html_changed when using $_() or $json() and {@html}
Svelte 5 : hydration_html_changed when using $_ or $json and {@html}Nov 15, 2024
Describe the bug
In Svelte 5, when svelte-i18n translations (
$_()
or$json()
) are used along with{@html }
then it fallbacks to default language.I wonder if I am doing something that should work or If I misunderstood how to use Svelte and svelte-i18n.
Screenshot to illustrate
Default translation file sample `fr.json` :
Translation file sample `en.json` :
Logs
Browser logs
To Reproduce
Repository : https://github.com/marc-bouvier/svelte-i18n-json-at-html
npm start
.In this application default language is french. It will fallback to french by default.
Expected behavior
When your main language is english, the paragraphs below should be in english... But, they fallback to default language : french.
Stacktraces
Stack trace : "hydration_html_changed"
Information about your project:
Your browser and the version: Brave [Version 1.71.123 Chromium: 130.0.6723.116 (Official Build) (arm64]
Your operating system: MacOS Sequoia 15.0 (24A335)
svelte-i18n
version : 4.0.1Whether your project uses Webpack or Rollup : Vite
Svelte version : 5.2.0
The text was updated successfully, but these errors were encountered: