Skip to content

Internationalization for svelte framework. Based on i18next ecosystem

License

Notifications You must be signed in to change notification settings

codenius/svelte-i18next

 
 

Repository files navigation

svelte-i18next Tweet

CI npm version bundle size License

Svelte wrapper for i18next

npm i svelte-i18next i18next

Implementation

This library wraps an i18next instance in a Svelte Store to observe i18next events so your Svelte components re-render e.g. when language is changed or a new resource is loaded by i18next.

Quick Start

i18n.js:

import i18next from "i18next";
import { createI18nStore } from "svelte-i18next";

i18next.init({
 lng: 'en',
 resources: {
    en: {
      translation: {
        "key": "hello world"
      }
    }
  },
  interpolation: {
    escapeValue: false, // not needed for svelte as it escapes by default
  }
});

export const i18n = createI18nStore(i18next);

App.svelte:

<script>
  import i18n from './i18n.js';
</script>

<div>
    {$i18n.t('key')}
</div>

See full example project: Svelte example

About

Internationalization for svelte framework. Based on i18next ecosystem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 68.1%
  • CSS 13.1%
  • Svelte 13.0%
  • HTML 5.8%