webui/src/hooks.server.ts

11 lines
284 B
TypeScript
Raw Normal View History

2023-11-19 19:27:22 +00:00
import type { Handle } from '@sveltejs/kit';
import { locale } from 'svelte-i18n';
2023-11-17 00:05:35 +00:00
export const handle: Handle = async ({ event, resolve }) => {
2023-11-19 19:27:22 +00:00
const lang = event.request.headers.get('accept-language')?.split(',')[0];
2023-11-17 00:05:35 +00:00
if (lang) {
2023-11-19 19:27:22 +00:00
locale.set(lang);
2023-11-17 00:05:35 +00:00
}
2023-11-19 19:27:22 +00:00
return resolve(event);
};