aboutsummaryrefslogtreecommitdiffstats
path: root/apps/kit/src/routes/(main)/+layout.ts
blob: f673067700733d34549c5437ffcddfbef1bfd4fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import type { Locales } from "$lib/i18n/i18n-types";
import { loadLocaleAsync, loadNamespaceAsync } from "$lib/i18n/i18n-util.async";
import type { LayoutLoad } from "./$types";

export const load: LayoutLoad<{ locale: Locales }> = async ({ url, params }) => {
    let lang = "en" as Locales;
    await loadLocaleAsync(lang);

    if (url.pathname.startsWith("/sign-in")) {
        await loadNamespaceAsync(lang, "sign-in");
    }
    if (url.pathname.startsWith("/sign-up")) {
        await loadNamespaceAsync(lang, "sign-up");
    }
    if (url.pathname.startsWith("/reset-password")) {
        await loadNamespaceAsync(lang, "reset-password");
    }
    return { locale: lang };
};