React Multilingual with redux
A simple and slim (Only 6KB) multi-lingual component for React with Redux without react-intl or react-i18n
Install
npm i react-redux-multilingual --save
Wiring it up
let reducers = let store = ReactDOM
Translations format
The translations props accepts object in this format
en: locale: 'en-US' messages: hello: 'how are you {name}' zh: locale: 'zh' messages: hello: '你好!你好吗 {name}'
Translate using hook
{ const t = return <div> </div> }
Translate using higher-order component (HOC)
const App = translate = return <div> </div> moduleexports =
Translate using Context
const App = { return <div> context </div> } AppcontextTypes = translate: ReactpropTypesfunc moduleexports = App
Setting the initial locale
Option 1: Pass your locale to initial state of your reducer
let store =
Option 2: Dispatch an action to change locale
let store = store