anhtuank7c / typesafe-i18n-demo-sveltekit

A small project demonstrating a `typesafe-i18n` integration with SvelteKit

Home Page:https://typesafe-i18n-demo-sveltekit.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

typesafe-i18n demo sveltekit

Here is a video for better context. SvelteKit has undergone some major changes since this video was published. For the most up-to-date way of handling i18n, please refer to the code in this repository.

This example demonstrates a typesafe-i18n-integration with SvelteKit.

LIVE-DEMO: https://typesafe-i18n-demo-sveltekit.vercel.app

It is a basic example and shows:

  • basic i18n setup of three different locales
  • auto-detecting user language preferences
  • full SSR support
  • SEO optimizations
  • locale switching
  • lazy loading of locales
  • persistent locale state via language routes
  • typesafety features of typesafe-i18n
  • plural rules
  • locale specific date-formatting

What is missing:

  • opinion how to localize slugs
    this highly depends where your data comes from. This will probably differ from project to project.
  • cross-links between your language slugs
    like mentioned above, this will differ from project to project. You can find useful resources here:\

add typesafe-i18n to an existing SvelteKit project

If you want to implement the solution in a existing project, you can take a look at the commit history to see a step-by-step guide.

JavaScript version

You can find the exact same example in a JavaScript only version here.
It offers the same typesafety features but instead of TypeScript files it is written in JavaScript with JsDoc comments.

learn more

If you want to know more about typesafe-i18n head over to the main repo:

https://github.com/ivanhofer/typesafe-i18n

About

A small project demonstrating a `typesafe-i18n` integration with SvelteKit

https://typesafe-i18n-demo-sveltekit.vercel.app


Languages

Language:TypeScript 67.6%Language:Svelte 19.8%Language:JavaScript 5.4%Language:SCSS 5.3%Language:HTML 1.9%