react-i18context

0.1.6 • Public • Published

react-i18context

How to run the demo

npm install
npm run start

How to use this in your project

npm install --save react-i18context

API

1.IntlProvider

// languages is an array object, key is the languae, see the demo
<IntlProvider languages={languages} locale="en">
    <App />
</IntlProvider>

2.FormatMsg

// id is the text you want to translate
<FormatMsg id="test" />

3.DefineLangue

// locale is the language you want to use when you click this button
<DefineLangue locale={lang}>
  <button>change language</button>
</DefineLangue>

4. InjectIntlLangWrapper

// in the FooComponent props will inject the changeLan method, so you can chnage the language manually
InjectIntlLangWrapper(FooComponent)

Dependencies (3)

Dev Dependencies (13)

Package Sidebar

Install

npm i react-i18context

Weekly Downloads

4

Version

0.1.6

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • flyingalex