diff --git a/svelte-app/src/hooks.server.ts b/svelte-app/src/hooks.server.ts index f8bea2b73..9dc38c554 100644 --- a/svelte-app/src/hooks.server.ts +++ b/svelte-app/src/hooks.server.ts @@ -29,11 +29,11 @@ export const handle = (async ({ event, resolve }) => { }; const lang = event.request.url.match( - new RegExp(`^.*(?:(?:.[a-z]{3})|(?:[a-z]+:[0-9]{4}))/(${APP_LANGS.join('|')})/?`) + new RegExp(`^(?:https?://)?[^/]+/(${APP_LANGS.join('|')})/?`) ), settings = event.cookies.get(LOCAL_SETTINGS_KEY); - if (lang) { + if (lang?.[1] && APP_LANGS.includes(lang[1])) { transforms.push((html) => html.replace(//, ``) ); diff --git a/svelte-app/src/routes/+layout.svelte b/svelte-app/src/routes/+layout.svelte index dcfeda852..140cb854f 100644 --- a/svelte-app/src/routes/+layout.svelte +++ b/svelte-app/src/routes/+layout.svelte @@ -8,6 +8,7 @@ import { classList } from 'svelte-body'; import { useMediaQuery } from 'svelte-breakpoints'; + import { browser } from '$app/environment'; import { navigating, page } from '$app/stores'; import { isDesktop } from '$helpers/responsive'; import { check as checkTranslations, currentLang, isLocalized, t } from '$i18n'; @@ -91,6 +92,7 @@ ? $page?.params?.lang : DEFAULT_APP_LANG ); + $: browser && (document.documentElement.lang = $currentLang);