redux-intl-react
React bindings for localization with MessageFormat and optional ECMA Intl support using redux-intl-connect.
PSA
If you're looking to support react-intl in redux, please use react-intl-redux instead.
The main difference between this library and the aforementioned is that this does not depend on the availability of ECMA Intl or it's polyfill.
About
redux-intl-react
provides React specific bindings for localization using redux-intl-connect with MessageFormat support.
Basic functionality does not require browser support or polyfill for ECMA-Intl. Should you require those, you can enable it. By setting ecmaSupport
to true
in the reducer.
Installation
Install the library:
npm install redux-intl-react redux react --save
Usage
;; const App = <Provider store=store> <FormattedMessage id='translation_id' /> </Provider>; ReactDOM;
Alias methods
Both updateIntl
and intlReducer
are aliased in this library. As such, you can do the following:
;
instead of
;
For usage instructions, please refer to the README of redux-intl-connect
Convenience methods
This library provides some components for convenince. These are essentially Higher Order Functions over react-redux
;
connect vs Redux connect
Instead of doing the following:
;; const Component = ...code; mapStateToProps mapDispatchToProps;
you can do this instead:
; const Component = ...code; mapStateToProps mapDispatchToPropsComponent;
Provider vs IntlProvider
Provider
is just a convenient wrapper for use if you are using react-redux
provider as your root.
In the event that you already have a custom provider in use that already wraps the redux provider, you can use IntlProvider instead.
;;; const App = <Provider store=store> <IntlProvider> <App /> </IntlProvider> </Provider>;
License
redux-intl-react
is BSD licensed
See also
Acknowledgement
Highly influenced by the following libraries: