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

i18n SSR #62

Closed
2 tasks
seilylook opened this issue Jul 4, 2023 · 1 comment
Closed
2 tasks

i18n SSR #62

seilylook opened this issue Jul 4, 2023 · 1 comment
Assignees

Comments

@seilylook
Copy link
Collaborator

seilylook commented Jul 4, 2023

  • Todo
    • ssr 제대로 돌아가는지 다른 사이트 비교
    • 강의, 자료 찾아서 적용 방법 수정
@seilylook seilylook self-assigned this Jul 4, 2023
@seilylook
Copy link
Collaborator Author

hooks.server.ts

import { currentLang } from '@store/i18n';
import type {Handle} from '@sveltejs/kit';
import {locale} from 'svelte-i18n';

export const ssr = true;
export const csr = true;

export const handle: Handle = async ({event, resolve}) => {
  const url = new URL(event.request.url)
  let lang = event.request.headers.get('accept-language')?.split(',')[0];
  lang = lang?.substring(3).toLowerCase();

  locale.set(lang)
  
  const response = await resolve(event)

  return response
};

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

2 participants