* move setLang() to a root layout

* fix: findLang only returns acceptable languages
* fix: fallback to use header x-lang if we haven't setLang yet
* fix: languageSchema, allow uppercase

Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-02-19 09:06:37 +00:00
parent d27163a915
commit 873183ec2f
45 changed files with 159 additions and 117 deletions

View File

@@ -20,25 +20,22 @@ import GTMScript from "@/components/TrackingSDK/GTMScript"
import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import type { LangParams, LayoutArgs } from "@/types/params"
export default async function RootLayout({
bookingwidget,
children,
params,
}: React.PropsWithChildren<
LayoutArgs<LangParams> & {
bookingwidget: React.ReactNode
}
>) {
setLang(params.lang)
preloadUserTracking()
const { defaultLocale, locale, messages } = await getIntl()
return (
<html lang={params.lang}>
<>
<head>
<AdobeSDKScript />
<GTMScript />
@@ -73,6 +70,6 @@ export default async function RootLayout({
</ServerIntlProvider>
</SessionProvider>
</body>
</html>
</>
)
}