Internationalization library for Svelte
Go to file
2018-07-26 23:33:02 -03:00
src Add deep merge for extensible locale dictionaries 2018-07-26 23:33:02 -03:00
test Add deep merge for extensible locale dictionaries 2018-07-26 23:33:02 -03:00
tools 👶 Initial commit 2018-07-25 22:50:55 -03:00
.editorconfig 👶 Initial commit 2018-07-25 22:50:55 -03:00
.gitignore 👶 Initial commit 2018-07-25 22:50:55 -03:00
.travis.yml 👶 Initial commit 2018-07-25 22:50:55 -03:00
code-of-conduct.md 👶 Initial commit 2018-07-25 22:50:55 -03:00
CONTRIBUTING.md 👶 Initial commit 2018-07-25 22:50:55 -03:00
LICENSE 👶 Initial commit 2018-07-25 22:50:55 -03:00
package-lock.json Add deep merge for extensible locale dictionaries 2018-07-26 23:33:02 -03:00
package.json Add deep merge for extensible locale dictionaries 2018-07-26 23:33:02 -03:00
README.md Add deep merge for extensible locale dictionaries 2018-07-26 23:33:02 -03:00
rollup.config.ts 👶 Initial commit 2018-07-25 22:50:55 -03:00
tsconfig.json 👶 Initial commit 2018-07-25 22:50:55 -03:00
tslint.json 👶 Initial commit 2018-07-25 22:50:55 -03:00

svelte-i18n

Internationalization for svelte

Work-in-progress

Usage

On the store

import i18n from 'svelte-i18n'
import { Store } from 'svelte/store'

const store = new Store()

/** i18n(svelteStore, arrayOfLocalesObjects) */
i18n(store, [
  {
    'pt-BR': {
      message: 'Mensagem',
      messages: {
        alert: 'Alerta',
        error: 'Erro'
      }
    },
    'en-US': {
      message: 'Message',
      messages: {
        alert: 'Alert',
        error: 'Error'
      }
    }
  },
  /** Locales are deeply merged */
  {
    'pt-BR': {
      messages: {
        warn: 'Aviso',
        success: 'Sucesso'
      }
    },
    'en-US': {
      messages: {
        warn: 'Warn',
        success: 'Success'
      }
    }
  }
])

On templates

<div>
  {$_('message')}: {$_.upper('messages.success')}
</div>

<!-- Will render for en-US -->
Message: SUCCESS