import type { Handle } from '@sveltejs/kit';
import { localeFromPath } from '$lib/i18n';

// Injecte l'attribut lang correct dans app.html selon la locale de la route.
export const handle: Handle = async ({ event, resolve }) => {
	const lang = localeFromPath(event.url.pathname);
	return resolve(event, {
		transformPageChunk: ({ html }) => html.replace('%lang%', lang)
	});
};
