ivanhofer/typesafe-i18n-demo-sveltekit

Static Site i18n

Opened this issue · 1 comments

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?

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.