Skip to content

Sapper minimal working example? #306

Answered by ivanhofer
jesperp asked this question in Q&A
Discussion options

You must be logged in to vote

Strange, sounds like a Sapper bug if it runs the preload function only on the client if it doesn't return anything.

Sou you could leave the return statement out. But you probably need the information on what locale is used. You could create language specific urls like '/en/...' and '/de/...' and read the information from the page store.

Or you can hack it together like in this example:

<script lang="ts" context="module">
	import { loadFormatters, loadLocaleAsync } from '../i18n/i18n-util.async'
	import { loadedLocales } from '../i18n/i18n-util'

	export async function preload(page, session) {
		const locale = 'en'
		await loadLocaleAsync(locale)

		// access the loaded translations and se…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@jesperp
Comment options

@ivanhofer
Comment options

@jesperp
Comment options

@ivanhofer
Comment options

Answer selected by jesperp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #304 on May 10, 2022 17:25.