1
|
|
|
/** @license |
2
|
|
|
* React Printable CV https://github.com/tomchen/react-printable-cv by Tom CHEN, MIT License |
3
|
|
|
*/ |
4
|
|
|
|
5
|
|
|
import React from 'react' |
6
|
|
|
import { render } from 'react-dom' |
7
|
|
|
import { createStore, compose, applyMiddleware } from 'redux' |
8
|
|
|
import { Provider } from 'react-redux' |
9
|
|
|
import thunk from 'redux-thunk' |
10
|
|
|
import i18n from 'i18next' |
11
|
|
|
import { initReactI18next } from 'react-i18next' |
12
|
|
|
import 'core-js/stable' |
13
|
|
|
import 'regenerator-runtime/runtime' |
14
|
|
|
import settings from 'Settings' |
15
|
|
|
import App from './App' |
16
|
|
|
import rootReducer from './reducers' |
17
|
|
|
|
18
|
|
|
i18n.use(initReactI18next).init({ |
19
|
|
|
ns: ['common'], |
20
|
|
|
defaultNS: 'common', |
21
|
|
|
lowerCaseLng: true, |
22
|
|
|
lng: settings.default_lang, |
23
|
|
|
fallbackLng: { |
24
|
|
|
default: ['en'], |
25
|
|
|
}, |
26
|
|
|
resources: {}, |
27
|
|
|
debug: process.env.NODE_ENV === 'development', |
28
|
|
|
keySeparator: false, |
29
|
|
|
nsSeparator: false, |
30
|
|
|
interpolation: { |
31
|
|
|
escapeValue: false, |
32
|
|
|
}, |
33
|
|
|
}) |
34
|
|
|
|
35
|
|
|
const langChangeMiddleware = ({ getState }) => { |
36
|
|
|
return (next) => (action) => { |
37
|
|
|
const previousLang = getState().lang |
38
|
|
|
const ret = next(action) |
39
|
|
|
const currentLang = getState().lang |
40
|
|
|
if (previousLang !== currentLang) { |
41
|
|
|
i18n.changeLanguage(currentLang) |
42
|
|
|
} |
43
|
|
|
return ret |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
const composeEnhancers = |
48
|
|
|
process.env.NODE_ENV === 'development' |
49
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose |
50
|
|
|
: compose |
51
|
|
|
|
52
|
|
|
const store = createStore( |
53
|
|
|
rootReducer, |
54
|
|
|
undefined, |
55
|
|
|
composeEnhancers(applyMiddleware(thunk, langChangeMiddleware)), |
56
|
|
|
) |
57
|
|
|
|
58
|
|
|
render( |
59
|
|
|
<Provider store={store}> |
60
|
|
|
<App /> |
61
|
|
|
</Provider>, |
62
|
|
|
document.getElementById('root'), |
63
|
|
|
) |
64
|
|
|
|