aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/routes/+layout.svelte11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 0485e71d..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,6 +21,13 @@
$: $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');