aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-05 17:20:44 -0800
committerAdam Soltys <[email protected]>2023-01-05 17:20:44 -0800
commitd961a61ba0f19cbb9c1782f308259e72dfb08f7f (patch)
treed31c4b51283f4eafc3ae3b1298d089fd5a331413 /src
parent5185988bd0d019c67faa14cf8063e66bede5c1fc (diff)
downloadcoinos-ui-d961a61ba0f19cbb9c1782f308259e72dfb08f7f.tar.gz
coinos-ui-d961a61ba0f19cbb9c1782f308259e72dfb08f7f.zip
support server side translations
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 {};
+};