diff options
| author | Adrien Hopkins <[email protected]> | 2022-08-16 20:16:38 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-16 20:16:38 +0000 |
| commit | fb8c38fec81de1afbdb00337d0af4c1c871cb3c3 (patch) | |
| tree | ba2df8ee23c7b17abd3cf290f488ab470f9b3a6e /src/routes/__layout.svelte | |
| parent | 36ff76c00dcd8aa52cf82fdf41c1feed669d2a6a (diff) | |
| parent | e99c489d61c3100d952dfedb799505122e36d33c (diff) | |
| download | coinos-ui-fb8c38fec81de1afbdb00337d0af4c1c871cb3c3.tar.gz coinos-ui-fb8c38fec81de1afbdb00337d0af4c1c871cb3c3.zip | |
Merge pull request #1 from coinos/i18n
Add Internationalization to CoinOS
Diffstat (limited to 'src/routes/__layout.svelte')
| -rw-r--r-- | src/routes/__layout.svelte | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 5ffdc9a0..8ac6f20f 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -1,6 +1,8 @@ <script> import { SvelteToast } from '@zerodevx/svelte-toast'; - import '../app.css'; + import '$lib/i18n'; + import { isLoading, locale } from 'svelte-i18n'; + import '../app.css'; import { onMount } from 'svelte'; import { connect } from '$lib/socket'; import { user, token } from '$lib/store'; @@ -15,6 +17,14 @@ let ready = false; onMount(() => { + // get locale from local storage + 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'); @@ -29,7 +39,7 @@ }); </script> -{#if ready} +{#if ready && !$isLoading} <SvelteToast options={{ reversed: true, intro: { y: 192 } }} /> <slot /> {:else} |
