2024-10-26 23:03:35 -04:00
|
|
|
<script lang="ts">
|
|
|
|
import { browser } from '$app/environment';
|
|
|
|
import { register, init, locale, waitLocale } from 'svelte-i18n';
|
2024-10-28 19:10:40 -04:00
|
|
|
import { UmamiAnalyticsEnv } from '@lukulent/svelte-umami';
|
2024-10-26 23:03:35 -04:00
|
|
|
export let data;
|
|
|
|
|
|
|
|
// Register your translations for each locale
|
|
|
|
register('en', () => import('../locales/en.json'));
|
|
|
|
register('es', () => import('../locales/es.json'));
|
2024-10-28 13:56:57 -04:00
|
|
|
register('fr', () => import('../locales/fr.json'));
|
|
|
|
register('de', () => import('../locales/de.json'));
|
2024-10-28 15:28:49 -04:00
|
|
|
register('it', () => import('../locales/it.json'));
|
|
|
|
register('zh', () => import('../locales/zh.json'));
|
|
|
|
register('nl', () => import('../locales/nl.json'));
|
2024-10-28 19:59:44 -04:00
|
|
|
register('sv', () => import('../locales/sv.json'));
|
2024-11-27 18:06:16 -05:00
|
|
|
register('pl', () => import('../locales/pl.json'));
|
2025-02-17 10:32:18 -05:00
|
|
|
register('ko', () => import('../locales/ko.json'));
|
2025-04-01 22:35:03 +02:00
|
|
|
register('no', () => import('../locales/no.json'));
|
2025-06-11 14:59:41 +07:00
|
|
|
register('ru', () => import('../locales/ru.json'));
|
2024-10-26 23:03:35 -04:00
|
|
|
|
2025-06-11 14:59:41 +07:00
|
|
|
let locales = ['en', 'es', 'fr', 'de', 'it', 'zh', 'nl', 'sv', 'pl', 'ko', 'no', 'ru'];
|
2024-11-27 11:27:18 -05:00
|
|
|
|
2024-10-26 23:03:35 -04:00
|
|
|
if (browser) {
|
|
|
|
init({
|
2024-11-27 11:27:18 -05:00
|
|
|
fallbackLocale: locales.includes(navigator.language.split('-')[0])
|
|
|
|
? navigator.language.split('-')[0]
|
|
|
|
: 'en',
|
2024-10-26 23:03:35 -04:00
|
|
|
initialLocale: data.locale
|
|
|
|
});
|
|
|
|
// get the locale cookie if it exists and set it as the initial locale if it exists
|
|
|
|
const localeCookie = document.cookie
|
|
|
|
.split(';')
|
|
|
|
.find((cookie) => cookie.trim().startsWith('locale='));
|
|
|
|
if (localeCookie) {
|
|
|
|
const localeValue = localeCookie.split('=')[1];
|
|
|
|
locale.set(localeValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-08 11:44:39 -04:00
|
|
|
import Navbar from '$lib/components/Navbar.svelte';
|
|
|
|
import Toast from '$lib/components/Toast.svelte';
|
|
|
|
import 'tailwindcss/tailwind.css';
|
|
|
|
|
2024-10-26 23:03:35 -04:00
|
|
|
// Create a promise that resolves when the locale is ready
|
|
|
|
export const localeLoaded = browser ? waitLocale() : Promise.resolve();
|
|
|
|
</script>
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-10-26 23:03:35 -04:00
|
|
|
{#await localeLoaded}
|
|
|
|
<!-- You can add a loading indicator here if needed -->
|
|
|
|
{:then}
|
|
|
|
<Navbar {data} />
|
|
|
|
<Toast />
|
|
|
|
<slot />
|
|
|
|
{/await}
|
2024-10-28 13:56:57 -04:00
|
|
|
|
2024-10-28 19:10:40 -04:00
|
|
|
<UmamiAnalyticsEnv />
|
|
|
|
|
2024-10-28 13:56:57 -04:00
|
|
|
<svelte:head>
|
|
|
|
<title>AdventureLog</title>
|
|
|
|
<meta
|
|
|
|
name="description"
|
|
|
|
content="Embark, explore, remember with AdventureLog. AdventureLog is the ultimate travel companion."
|
|
|
|
/>
|
|
|
|
</svelte:head>
|