aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/translations/index.js2
-rw-r--r--src/routes/+layout.js8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js
index 7b909711..9c798530 100644
--- a/src/lib/translations/index.js
+++ b/src/lib/translations/index.js
@@ -50,4 +50,4 @@ const config = {
]
};
-export const { t, l, locales, locale } = new i18n(config);
+export const { t, loading, locales, locale, loadTranslations } = new i18n(config);
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 {};
+};