Created
November 20, 2015 08:12
-
-
Save ooflorent/915b145e58bbed00623f to your computer and use it in GitHub Desktop.
Revisions
-
ooflorent created this gist
Nov 20, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ import { applyMiddleware, compose, createStore } from "redux" import { reduxReactIntl } from "redux-react-intl" import thunk from "redux-thunk" import rootReducer from "./reducers" const createStoreFactory = compose( applyMiddleware(thunk), reduxReactRouter({ routes, createHistory }) ) const finalCreateStore = createStoreFactory(createStore) export default function configureStore(initialState) { const store = finalCreateStore(rootReducer, initialState) return store } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import { setIntlState } from "redux-react-intl" import { addLocaleData } from "react-intl" import __intlEN from "react-intl/lib/locale-data/en" import __intlFR from "react-intl/lib/locale-data/fr" addLocaleData(__intlEN) addLocaleData(__intlFR) import localeEN from "translations/en.json" import localeFR from "translations/fr.json" function compileLocale(locale, { messages, formats = {} }) { return { locale, messages, formats } } const LOCALES = { "en": compileLocale("en", localeEN), "fr": compileLocale("fr", localeFR), } export function setLocale(locale) { return setIntlState(LOCALES[locale]) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import React from "react" import { render } from "react-dom" import { Provider } from "react-redux" import { ReduxIntl } from "redux-react-intl" import { setLocale } from "./intlActions" import configureStore from "./configureStore" const store = configureStore() store.dispatch((dispatch) => { dispatch(setLocale("fr")) }) const app = ( <Provider store={ store }> <ReduxIntl> {/* Your app, or router */} </ReduxIntl> </Provider> ) render(app, document.getElementById("root")) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ import { combineReducers } from "redux" import { intlStateReducer as intl } from "redux-react-intl" export default combineReducers({ // Other reducers go here intl })