2019-11-16 20:46:19 +00:00
|
|
|
import i18n from 'i18next';
|
|
|
|
import { initReactI18next } from 'react-i18next';
|
2022-06-11 18:04:09 +00:00
|
|
|
import I18NextHttpBackend, { BackendOptions } from 'i18next-http-backend';
|
|
|
|
import I18NextMultiloadBackendAdapter from 'i18next-multiload-backend-adapter';
|
|
|
|
|
|
|
|
// If we're using HMR use a unique hash per page reload so that we're always
|
|
|
|
// doing cache busting. Otherwise just use the builder provided hash value in
|
|
|
|
// the URL to allow cache busting to occur whenever the front-end is rebuilt.
|
|
|
|
const hash = module.hot ? Date.now().toString(16) : process.env.WEBPACK_BUILD_HASH;
|
2019-11-16 20:46:19 +00:00
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
i18n.use(I18NextMultiloadBackendAdapter)
|
2019-11-16 20:46:19 +00:00
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
2022-06-11 18:04:09 +00:00
|
|
|
debug: process.env.DEBUG === 'true',
|
2019-11-16 20:46:19 +00:00
|
|
|
lng: 'en',
|
|
|
|
fallbackLng: 'en',
|
|
|
|
keySeparator: '.',
|
|
|
|
backend: {
|
2022-06-11 18:04:09 +00:00
|
|
|
backend: I18NextHttpBackend,
|
|
|
|
backendOption: {
|
2022-06-11 18:52:41 +00:00
|
|
|
loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
|
|
|
|
queryStringParams: { hash },
|
2022-06-11 18:04:09 +00:00
|
|
|
allowMultiLoading: true,
|
|
|
|
} as BackendOptions,
|
|
|
|
} as Record<string, any>,
|
|
|
|
interpolation: {
|
|
|
|
// Per i18n-react documentation: this is not needed since React is already
|
|
|
|
// handling escapes for us.
|
|
|
|
escapeValue: false,
|
2019-11-16 20:46:19 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|