localization v2

This commit is contained in:
Sean Morley
2024-10-28 13:56:57 -04:00
parent 6cf62cfb82
commit 91c0ec8c07
18 changed files with 432 additions and 101 deletions

View File

@@ -49,5 +49,15 @@ export const actions: Actions = {
} else {
return redirect(302, '/');
}
},
setLocale: async ({ url, cookies }) => {
const locale = url.searchParams.get('locale');
// change the theme only if it is one of the allowed themes
if (locale && ['en', 'es'].includes(locale)) {
cookies.set('locale', locale, {
path: '/',
maxAge: 60 * 60 * 24 * 365
});
}
}
};