Commit 5e46928d authored by Oleksii Savran's avatar Oleksii Savran

Removed adding unused locales

parent a55b67f6
......@@ -17,6 +17,7 @@ import { i18nClient } from '../i18n/i18n-client';
import detectLocaleFromPath from '../server/middleware/detectLocaleFromPath';
import getDir from '../server/middleware/detectDirection';
import { receiveLang } from 'actions/applicationConfig';
import TimeAgo from 'javascript-time-ago';
// JSS & MUI
import { MuiThemeProvider } from '@material-ui/core/styles';
......@@ -45,6 +46,8 @@ const SsrI18nProvider = withSSR()(I18nextProvider) as any;
// Configure axios for client
configureBackendApi({ apiUrl: store.getState().applicationConfig.apiUrl || process.env.API_URL || 'http://localhost:8080' });
// Set date's locale for client
import(`javascript-time-ago/locale/${detectedLang}`).then((locale) => TimeAgo.addLocale(locale));
if (__PRELOADED_STATE__ === undefined) {
......
......@@ -14,6 +14,7 @@ import { I18nextProvider } from 'react-i18next';
import thunk from 'redux-thunk';
import rootReducer from 'reducers';
import languages from 'data/Languages';
import TimeAgo from 'javascript-time-ago';
// import { create as createJss } from 'jss';
// import jssPreset from 'jss-preset-default';
......@@ -69,6 +70,7 @@ const prerenderer = (html, errHtml) => (req, res) => {
const locale = detectLocaleFromPath(config.frontendPath, pathname, 0);
// console.log('Detected locale for SSR is', locale);
req.i18n.changeLanguage(locale);
import(`javascript-time-ago/locale/${locale}`).then((timeAgoLocale) => TimeAgo.locale(timeAgoLocale));
}
function renderView() {
......
......@@ -3,7 +3,6 @@ import { WithTranslation, withTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as _ from 'lodash';
import languages from 'data/Languages';
import { updateHistory } from 'actions/history';
import { loadCrops } from 'crop/actions/public';
......@@ -14,12 +13,6 @@ import { loadIso3Decodings } from 'geo/actions/public';
import { withRouter } from 'react-router-dom';
import TimeAgo from 'javascript-time-ago';
languages.forEach(async (lang) => {
const locale = await import(/* webpackMode:"lazy", webpackChunkName: "vendors" */`javascript-time-ago/locale/${lang.short}`);
TimeAgo.addLocale(locale);
});
// required cause of infinite memory leak for chunking and node-12
import(/* webpackMode:"lazy", webpackChunkName: "vendors" */'react-autosuggest');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment