Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced router (default locale no prefix) with static adapter? #167

Open
kratos-digital opened this issue Jan 28, 2024 · 2 comments
Open

Comments

@kratos-digital
Copy link

How to use static adapter with example in locale-router-advanced? What I need is to have my default locale without prefix, but files should be built statically. Static adapter works with locale-router-static, but every language has prefix there and the index.html only has JS redirection to default locale.

In svelte.config.js I have this:

const config = {
	kit: {
		adapter: adapter({
			pages: 'build',
			assets: 'build',
			fallback: undefined,
			precompress: false,
			strict: true
		}),
		prerender: {
			// This works when all locales are prefixed
			// entries: ['/'].concat(supportedLocales.reduce((acc, locale) => [...acc, `/${locale}`], ['*']))
			entries: ['*', '/', '/en'] // throws error below (hr default locale, en secondary locale)
			// entries: ['*', '/en'] // generates only files for english locale, and nothing for default
		}
	},
	preprocess: vitePreprocess(),
	compilerOptions: {
		customElement: true
	}
};

All I get is this useless error:

node:internal/event_target:1083
  process.nextTick(() => { throw err; });
                           ^
Error: 500 /
@ansbr
Copy link

ansbr commented Jan 30, 2024

I can't find example without prefix for default locale in repository, that's very sad. If someone can make example, it will be really cool...

@kikky7
Copy link

kikky7 commented Jan 30, 2024

There is example https://github.com/sveltekit-i18n/lib/tree/master/examples/locale-router-advanced, but it doesn't work with static adapter.

To make it work with static adapter, check out locale-router-static example and set lang param as optional (double square brackets). Then the default locale will be created both in root and language folder. And on server you can use rewrite rules to redirect default locale folder to root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants