Created
November 20, 2015 08:12
-
-
Save ooflorent/915b145e58bbed00623f to your computer and use it in GitHub Desktop.
This file contains 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 characters
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 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 characters
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 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 characters
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 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 characters
import { combineReducers } from "redux" | |
import { intlStateReducer as intl } from "redux-react-intl" | |
export default combineReducers({ | |
// Other reducers go here | |
intl | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some questions: