diff --git a/src/i18n.js b/src/i18n.js index 3e51b97..0d8dd96 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -4,31 +4,31 @@ import LanguageDetector from 'i18next-browser-languagedetector'; import { reactI18nextModule } from 'react-i18next'; import config from './config'; -i18n - .use(XHR) - .use(LanguageDetector) - .use(reactI18nextModule) - .init({ - fallbackLng: "en", - // Only attempt to load the base language, for example only attempt en and not en-US - load: "languageOnly", - namespaces: ['common', 'dashboard', 'footer', 'lists', 'location', 'login', 'query-log'], - defaultNS: "common", - fallbackNS: ['dashboard', 'footer', 'lists', 'location', 'login', 'query-log'], - nsSeparator: false, - keySeparator: false, - debug: config.developmentMode, - interpolation: { - // Handled by React - escapeValue: false - }, - backend: { - loadPath: process.env.PUBLIC_URL + "/i18n/{{lng}}/{{ns}}.json" - }, - react: { - // Wait until translations are loaded before rendering - wait: true - } - }); - -export default i18n; +export function setupI18n() { + i18n + .use(XHR) + .use(LanguageDetector) + .use(reactI18nextModule) + .init({ + fallbackLng: "en", + // Only attempt to load the base language, for example only attempt en and not en-US + load: "languageOnly", + ns: ['common', 'dashboard', 'footer', 'lists', 'location', 'login', 'query-log'], + defaultNS: "common", + fallbackNS: ['dashboard', 'footer', 'lists', 'location', 'login', 'query-log'], + nsSeparator: false, + keySeparator: false, + debug: config.developmentMode, + interpolation: { + // Handled by React + escapeValue: false + }, + backend: { + loadPath: process.env.PUBLIC_URL + "/i18n/{{lng}}/{{ns}}.json" + }, + react: { + // Wait until translations are loaded before rendering + wait: true + } + }); +} diff --git a/src/index.js b/src/index.js index cb245fd..c2980c5 100644 --- a/src/index.js +++ b/src/index.js @@ -13,18 +13,17 @@ import ReactDOM from 'react-dom'; import { HashRouter, Route, Switch } from 'react-router-dom' import 'ionicons/dist/css/ionicons.min.css'; import Full from './containers/Full' -import i18n from './i18n'; -import { I18nextProvider } from 'react-i18next' +import { setupI18n } from './i18n'; + +setupI18n(); ReactDOM.render( ( - - - - - - - + + + + + ), document.getElementById('root') );