From d961a61ba0f19cbb9c1782f308259e72dfb08f7f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Jan 2023 17:20:44 -0800 Subject: support server side translations --- src/routes/+layout.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/routes/+layout.js (limited to 'src/routes/+layout.js') diff --git a/src/routes/+layout.js b/src/routes/+layout.js new file mode 100644 index 00000000..add74f87 --- /dev/null +++ b/src/routes/+layout.js @@ -0,0 +1,8 @@ +import { loadTranslations, locale } from '$lib/translations'; +export const load = async ({ url }) => { + const { pathname } = url; + const defaultLocale = 'en'; // get from cookie, user session, ... + const initLocale = locale.get() || defaultLocale; // set default if no locale already set + await loadTranslations(initLocale, pathname); // keep this just before the `return` + return {}; +}; -- cgit v1.2.3