2019-11-16 21:46:19 +01:00
|
|
|
import i18n from 'i18next';
|
|
|
|
import { initReactI18next } from 'react-i18next';
|
2022-06-11 20:04:09 +02: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.
|
2022-11-25 21:25:03 +01:00
|
|
|
const hash = Date.now().toString(16);
|
2019-11-16 21:46:19 +01:00
|
|
|
|
2022-06-26 21:13:52 +02:00
|
|
|
i18n.use(I18NextMultiloadBackendAdapter)
|
2019-11-16 21:46:19 +01:00
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
2022-06-11 20:04:09 +02:00
|
|
|
debug: process.env.DEBUG === 'true',
|
2019-11-16 21:46:19 +01:00
|
|
|
lng: 'en',
|
|
|
|
fallbackLng: 'en',
|
|
|
|
keySeparator: '.',
|
|
|
|
backend: {
|
2022-06-11 20:04:09 +02:00
|
|
|
backend: I18NextHttpBackend,
|
|
|
|
backendOption: {
|
2022-06-11 20:52:41 +02:00
|
|
|
loadPath: '/locales/locale.json?locale={{lng}}&namespace={{ns}}',
|
|
|
|
queryStringParams: { hash },
|
2022-06-11 20:04:09 +02: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 21:46:19 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|