👽 🐛 Le simulateur est affiché en français sur mon-entreprise

pull/438/head
Johan Girod 2018-11-29 17:41:56 +01:00
parent 0e8f113cd1
commit 07e6388541
2 changed files with 16 additions and 4 deletions

View File

@ -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 (

View File

@ -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<string>,
+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,