NishuGoel / svelte-i18next

Internationalization for svelte framework. Based on i18next ecosystem
https://npmjs.com/package/svelte-i18next
MIT License
51 stars 11 forks source link

using dev (`vite dev`), every other page refresh.. `$isLoading` doesn't update from `true` to `false` #16

Open warren-bank opened 4 months ago

warren-bank commented 4 months ago

I found a workaround that seems to work OK.. just thought I'd drop a note, in case anyone wants to dig deeper and find a better fix.

The issue started when:

After doing so, any +page.svelte containing:

<pre>$isLoading = {$isLoading} ({typeof $isLoading})</pre>

{#if $isLoading === false}
  OK!
{/if}

..would finish loading about 50% to 70% of the time

My workaround was to modify how I initialize the libraries in my root layout:

import i18next from 'i18next'
import {createI18nStore, isLoading} from 'svelte-i18next'

i18next
  .init(
    {...},
    (error) => {
      isLoading.set(!!error)
    }
  )