diff options
| author | secondl1ght <[email protected]> | 2022-08-24 18:47:21 -0400 |
|---|---|---|
| committer | secondl1ght <[email protected]> | 2022-08-24 18:47:21 -0400 |
| commit | 8f8f85983d2f4cb734ed15b33ebc140028711733 (patch) | |
| tree | 1bb87287c2dbeb681be1fb83971eea945fe19926 /src/routes/+layout.svelte | |
| parent | 80d2b8db2b85829ee539814c176ebcf354939ad6 (diff) | |
| parent | e54f0cf98d65e71153c4613a1e9a9b845b9f8f87 (diff) | |
| download | coinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.tar.gz coinos-ui-8f8f85983d2f4cb734ed15b33ebc140028711733.zip | |
Merge branch 'master' of github.com:coinos/coinos-ui-v2
Diffstat (limited to 'src/routes/+layout.svelte')
| -rw-r--r-- | src/routes/+layout.svelte | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 185eb140..5eab20bd 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -9,7 +9,9 @@ import { goto } from '$app/navigation'; import { LoadingSplash } from '$comp'; import { warning, protectedRoutes } from '$lib/utils'; - import { t } from '$lib/translations'; + import { t, locale } from '$lib/translations'; + + const localeLocalStorageKey = 'sveltekit-i18n-locale'; $: $token = data.token; @@ -19,13 +21,18 @@ $: $selectedRate = data.user && $rate * (data.rates[data.user.currency] / data.rates.USD); onMount(() => { + let localStorageLocale = localStorage.getItem(localeLocalStorageKey); + if (localStorageLocale) locale.set(localStorageLocale); + + locale.subscribe((lng) => { + if (lng) localStorage.setItem(localeLocalStorageKey, lng); + }); + if (protectedRoutes.find((p) => $page.url.pathname.match(p))) { if (!$token) { goto('/login'); warning($t('error.signIn')); } - } else { - ready = true; } connect(); |
