diff --git a/src/client/configs/PortalConfig.js b/src/client/configs/PortalConfig.js index 5bda0c961e658a55cf20289b3d99a229ff3a440e..ea2ebf2c84879dae4c38937ad40db15f006be489 100644 --- a/src/client/configs/PortalConfig.js +++ b/src/client/configs/PortalConfig.js @@ -1,3 +1,15 @@ export default { - portalID: 'sampo' + portalID: 'sampo', + localeConfig: [ + { + id: 'en', + label: 'English', + filename: 'localeEN.json' + }, + { + id: 'fi', + label: 'English', + filename: 'localeFI.json' + } + ] } diff --git a/src/client/epics/index.js b/src/client/epics/index.js index 8615217615b38c4a0ef6b0496a99127e0fabc920..2f185b19e3699096da2d91d6a134ed7c34cb11d0 100644 --- a/src/client/epics/index.js +++ b/src/client/epics/index.js @@ -11,8 +11,6 @@ import { } from 'rxjs/operators' import { combineEpics, ofType } from 'redux-observable' import intl from 'react-intl-universal' -import localeEN from '../translations/sampo/localeEN.json' -import localeFI from '../translations/sampo/localeFI.json' import { stateToUrl, pickSelectedDatasets } from '../helpers/helpers' import querystring from 'querystring' import { @@ -53,7 +51,13 @@ import { updateKnowledgeGraphMetadata, fetchGeoJSONLayersFailed } from '../actions' -import { documentFinderAPIUrl } from '../configs/sampo/GeneralConfig' +import portalConfig from '../configs/PortalConfig' +const { portalID, localeConfig } = portalConfig +const { documentFinderAPIUrl } = await import(`../configs/${portalID}/GeneralConfig`) +export const availableLocales = {} +for (const locale of localeConfig) { + availableLocales[locale.id] = await import(`../translations/${portalID}/${locale.filename}`) +} /* * Note that all code inside the 'client' folder runs on the browser, so there is no 'process' object as in Node.js. @@ -61,11 +65,6 @@ import { documentFinderAPIUrl } from '../configs/sampo/GeneralConfig' */ const apiUrl = process.env.API_URL -export const availableLocales = { - en: localeEN, - fi: localeFI -} - let backendErrorText = null const fetchPaginatedResultsEpic = (action$, state$) => action$.pipe( diff --git a/src/client/index.js b/src/client/index.js index f1775aa41029c8952ea2c4efdc43de905a0b42ab..eb77904b36253a4efafa4eb5dad8adde214ccf81 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -8,7 +8,7 @@ import configureStore from './configureStore' import App from './components/App' import { availableLocales } from './epics/index.js' import { loadLocales } from './actions' -import { defaultLocale } from './configs/sampo/GeneralConfig' + import { updateLocaleToPathname } from './helpers/helpers' import CircularProgress from '@material-ui/core/CircularProgress' import purple from '@material-ui/core/colors/purple' @@ -18,6 +18,10 @@ import '@nosferatu500/react-sortable-tree/style.css' import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import 'mapbox-gl/dist/mapbox-gl.css' +import portalConfig from './configs/PortalConfig' +const { portalID } = portalConfig +const { defaultLocale } = await import(`./configs/${portalID}/GeneralConfig`) + const store = configureStore() // init locale