react-i18context
v0.1.6
Published
simple react i18 component
Downloads
4
Maintainers
Readme
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)