Skip to content

haris44/Simple-i18n

Repository files navigation

Simple i18n 1.0

Build Status

Coverage Status

Dependency Status

Very short and simple library to use i18n. You can use this library without React !!!

Import properties

You can load external JSON object with webpack for example.

import fr from '../properties/properties_FR.json'

Or use a simple javascript object

const fr = { hello : "Bonjour !"}

Init the library

On your index.js page, import i18n library.

First parameter is a Javascript object with every property.

import i18n from 'simple-react-i18n'
i18n.addLang(fr, ['fr', 'FR'])
i18n.addLang(en, 'default')
i18n.init()

Use JSON properties

i18n work as a closure function. Init langage on the main component, and use it

On your component:

import i18n from 'simple-react-i18n'
...
{ i18n.props }

Installation

You can fetch the package using npm

npm install simple-react-i18n

Changelog

1.0

  • Add polyfill for Proxy object
  • Change import method, use CommonJS2
  • Add Unit Test
  • Fix minor bug
  • Update Readme

Releases

No releases published

Packages

No packages published