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

Sapper Usage in Preload #52

Open
semenodp opened this issue Feb 24, 2020 · 2 comments
Open

Sapper Usage in Preload #52

semenodp opened this issue Feb 24, 2020 · 2 comments
Assignees

Comments

@semenodp
Copy link

Hello. What would be the best way to both structure locales files in sapper application and to both request data and load locales in preload function? Currently I am storing separate locales files for each page and then preload the data like that. But there seems to be a lot of cases where data does not load. Any suggestions?

<script context="module"> 
  import { register, waitLocale } from 'svelte-i18n'  
  register('en', () => import('./_locales/en.json'))  
  register('ru', () => import('./_locales/ru.json'))  
   export async function preload({ params, query }, session) {
      const res = await this.fetch('tournaments/${params.tournamentId}.json');
      const data = await res.json();
        if (res.status === 200) {
            await waitLocale()
            return { 
              tournament: data.tournament,
              id: params.tournamentId
            }
        } else {
          this.error(res.status, data.message);
        } 
    }
 }
@kaisermann
Copy link
Owner

@semenodp Hey @semenodp 👋 Sorry for taking so long! Can you try with version 3.0.4? I've just fixed an issue regarding partial dictionaries not being correctly loaded

@kaisermann kaisermann self-assigned this May 31, 2020
@Tal500
Copy link

Tal500 commented Apr 30, 2022

It could be closed when and if pull request #179 will be merged.

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