1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-01 15:11:21 +01:00
immich/web/src/routes/+layout.ts
2024-06-07 11:35:05 -05:00

30 lines
908 B
TypeScript

import { defaultLang, langs } from '$lib/constants';
import { lang } from '$lib/stores/preferences.store';
import { defaults } from '@immich/sdk';
import { init, register } from 'svelte-i18n';
import { get } from 'svelte/store';
import type { LayoutLoad } from './$types';
export const ssr = false;
export const csr = true;
export const load = (async ({ fetch }) => {
// set event.fetch on the fetch-client used by @immich/sdk
// https://kit.svelte.dev/docs/load#making-fetch-requests
// https://github.com/oazapfts/oazapfts/blob/main/README.md#fetch-options
defaults.fetch = fetch;
for (const { code, loader } of langs) {
register(code, loader);
}
const preferenceLang = get(lang);
await init({ fallbackLocale: preferenceLang === 'dev' ? 'dev' : defaultLang.code, initialLocale: preferenceLang });
return {
meta: {
title: 'Immich',
},
};
}) satisfies LayoutLoad;