diff options
| author | Adam Soltys <[email protected]> | 2022-08-22 15:49:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-22 15:49:08 -0700 |
| commit | 0ebb60f986682ad8d3538c2fd1d708a861e0b1fb (patch) | |
| tree | 7a824114c5fd70fe42758d35d215fefdec8a7599 /src/routes/+layout.svelte | |
| parent | b1843d46dd406f6f7a657ab680407644f096e2c3 (diff) | |
| download | coinos-ui-0ebb60f986682ad8d3538c2fd1d708a861e0b1fb.tar.gz coinos-ui-0ebb60f986682ad8d3538c2fd1d708a861e0b1fb.zip | |
migrate to sveltekit-i18n
Diffstat (limited to 'src/routes/+layout.svelte')
| -rw-r--r-- | src/routes/+layout.svelte | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 1de48b9e..dfe52894 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,7 +1,5 @@ <script> import { SvelteToast } from '@zerodevx/svelte-toast'; - import '$lib/i18n'; - import { isLoading, locale } from 'svelte-i18n'; import '../app.css'; import { onMount } from 'svelte'; import { connect } from '$lib/socket'; @@ -11,7 +9,7 @@ import { goto } from '$app/navigation'; import { LoadingSplash } from '$comp'; import { warning, protectedRoutes } from '$lib/utils'; - import { _ } from 'svelte-i18n'; + import { t } from '$lib/translations'; $: $token = data.token; @@ -23,17 +21,10 @@ let ready = false; onMount(() => { - let localStorageLocale = localStorage.getItem('svelte-i18n-locale'); - if (localStorageLocale) locale.set(localStorageLocale); - - locale.subscribe((lng) => { - if (lng) localStorage.setItem('svelte-i18n-locale', lng); - }); - if (protectedRoutes.find((p) => $page.url.pathname.match(p))) { if (!$token) { goto('/login'); - warning($_('error.signIn')); + warning($t('error.signIn')); } user.subscribe((u) => u?.username && (ready = true)); } else { @@ -44,7 +35,7 @@ }); </script> -{#if ready && !$isLoading} +{#if ready} <SvelteToast options={{ reversed: true, intro: { y: 192 } }} /> <slot /> {:else} |
