Does not even work in sveltekit #740
-
3 hours trying to understand why it's wont work when I import anything related to typesafe-i18n "Discussion #674" to +layout.svelte the dom stops updating when any change happens for some reason is there any way to fix this |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I use a store to save the selected language like this: import type { Locales } from '$i18n/i18n-types';
import { localStorageStore } from '@skeletonlabs/skeleton';
import type { Writable } from 'svelte/store';
export const Lang: Writable<Locales> = localStorageStore('lang', 'en'); and I create a button component to change the language: <script lang="ts">
import { setLocale } from '$i18n/i18n-svelte';
import { locale } from '$i18n/i18n-svelte';
import { Lang } from '$lib/stores/lang';
import { fade } from 'svelte/transition';
$: Lang.set($locale);
</script>
<div class="hover:dark:text-tertiary-500 hover:text-tertiary-800">
{#key $locale}
<div in:fade>
{#if $locale !== 'ar'}
<button
on:click={() => {
setLocale('ar');
}}>AR</button
>
{:else}
<button
on:click={() => {
setLocale('en');
}}>EN</button
>
{/if}
</div>
{/key}
</div> and this in +layout.svelte import { Lang } from '$lib/stores/lang';
import { LL, setLocale } from '$i18n/i18n-svelte';
import { loadAllLocales } from '$i18n/i18n-util.sync';
import { i18n } from 'typesafe-i18n';
loadAllLocales();
const locale = 'en';
// @ts-ignore
const L = i18n(locale);
setLocale($Lang); |
Beta Was this translation helpful? Give feedback.
-
Finally, after a long day of debugging, I found out that clearing site cookies and cache fix this problem |
Beta Was this translation helpful? Give feedback.
Finally, after a long day of debugging, I found out that clearing site cookies and cache fix this problem
you should add this to docs or fix it