typesafe-i18n-demo-sveltekit icon indicating copy to clipboard operation
typesafe-i18n-demo-sveltekit copied to clipboard

Static Site i18n

Open marksteven opened this issue 2 years ago • 1 comments
trafficstars

Hello Ivan, I would like to be able to build a static page Sveltekit site and also use your typesafe-i18n

So if I am to use sveltejs/adapter-static on the svelte.config.js page it requires import adapter from "@sveltejs/adapter-static";

and the adapter to build all the pages adapter: adapter({ pages: "build", assets: "build", fallback: undefined, precompress: false, strict: true, }),

plus export const prerender = true; on the main +layout.js page

How would I go about integrating typesafe-i18n into site? I am thinking it may not possible but hoping you have a solution?

marksteven avatar Jul 10 '23 13:07 marksteven

You can use the same code as you would write a server-application. The only thing that really changes is that you can't use the / route to detect the user's preferred locale and to redirect the user to e.g. /de. So you will need to remove that part from hooks.server.ts and create a routes/+page.js file and do the redirect inside the load function.

ivanhofer avatar Jul 10 '23 18:07 ivanhofer