@jill64/svelte-i18n

npm-version npm-license npm-download-month npm-min-size ci.yml website

🌍 i18n toolkit for SvelteKit

β–· Installation

https://svelte-i18n.jill64.dev/

Current Language : English ($locale = en)

Top Page

<!-- +page.svelte -->
<script>
  import { translate } from 'i18n.js'
</script>

<h2>
  {$translate({
    en: 'Top Page',
    ja: 'γƒˆγƒƒγƒ—γƒšγƒΌγ‚Έ'
  })}
</h2>

Example Schema

// i18n.js
import { init } from '@jill64/svelte-i18n'

export const { match, altered, locale, translate, attach } = init({
  locales: ['en', 'ja'],
  slug: '[locale=locale]',
  defaultLocale: 'en'
})

SSR Support

// hooks.server.js
import { attach } from 'i18n.js'

export const handle = attach