0.4.1 • Published 8 months ago

factorial-i18n v0.4.1

Weekly downloads
155
License
MIT
Repository
github
Last release
8 months ago

Factorial i18n

Minimal library for dealing i18n. Supports pluralization and interpolation.

Build Status JavaScript Style Guide

Installation

npm install factorial-i18n --save
yarn add factorial-i18n

Example

const translations = {
  en: {
    common: { hello: 'hello %{name}', },
    beers: { one: '%{count} beer', other: '%{count} beers' }
  },
  es: {
    common: { hello: 'hola %{name}', },
    beers: { one: '%{count} cerveza', other: '%{count} cervezas' }
  }
}

const i18n = new I18n()

i18n.setTranslations(translations)
i18n.setLocale('es')
i18n.t('common.hello') // => Hola
i18n.tp('common.beers', { count: 0 }) // => 0 cervezas
i18n.tp('common.beers', { count: 1 }) // => 1 cerveza

Where is it used?

Developed and battle tested in production in Factorial

0.4.1

8 months ago

0.4.0

1 year ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago