From 07e638854169d3da1e4b1987f5048f9ea193556f Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 29 Nov 2018 17:41:56 +0100 Subject: [PATCH] =?UTF-8?q?:alien:=20:bug:=20Le=20simulateur=20est=20affic?= =?UTF-8?q?h=C3=A9=20en=20fran=C3=A7ais=20sur=20mon-entreprise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Provider.js | 9 +++++---- source/reducers/rootReducer.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/Provider.js b/source/Provider.js index b8973c5e7..307345ea0 100644 --- a/source/Provider.js +++ b/source/Provider.js @@ -8,10 +8,10 @@ import { Provider } from 'react-redux' import { Router } from 'react-router-dom' import reducers from 'Reducers/rootReducer' import { applyMiddleware, compose, createStore } from 'redux' +import { enableBatching } from 'redux-batched-actions' import thunk from 'redux-thunk' import computeThemeColours from 'Ui/themeColours' import { getIframeOption, inIframe } from './utils' -import { enableBatching } from 'redux-batched-actions' let initialStore = { themeColours: computeThemeColours(getIframeOption('couleur')) @@ -50,15 +50,16 @@ export default class Layout extends PureComponent { ...props.reduxMiddlewares ) ) + if (this.props.language) { + i18next.changeLanguage(this.props.language) + this.props.initialStore.lang = this.props.language + } this.store = createStore( enableBatching(reducers), { ...initialStore, ...this.props.initialStore }, storeEnhancer ) this.props.onStoreCreated(this.store) - if (this.props.language) { - i18next.changeLanguage(this.props.language) - } } render() { return ( diff --git a/source/reducers/rootReducer.js b/source/reducers/rootReducer.js index 0f9039848..286df0c60 100644 --- a/source/reducers/rootReducer.js +++ b/source/reducers/rootReducer.js @@ -17,6 +17,7 @@ import { combineReducers } from 'redux' import { reducer as formReducer } from 'redux-form' import computeThemeColours from 'Ui/themeColours' import { simulationTargetNames } from '../config.js' +import i18n from '../i18n' import inFranceAppReducer from './inFranceAppReducer' import storageReducer from './storageReducer' import type { Action } from 'Types/ActionsTypes' @@ -65,6 +66,15 @@ function activeTargetInput(state = null, { type, name }) { } } +function lang(state = i18n.language, { type, lang }) { + switch (type) { + case 'SWITCH_LANG': + return lang + default: + return state + } +} + type ConversationSteps = {| +foldedSteps: Array, +unfoldedStep: ?string, @@ -156,6 +166,7 @@ export default reduceReducers( // this is handled by redux-form, pas touche ! form: formReducer, conversationSteps, + lang, targetNames: defaultTo(simulationTargetNames), themeColours, explainedVariable,