react-app-typescript-template/src/config/i18next/i18next.ts
2020-09-21 10:06:53 +07:00

28 lines
710 B
TypeScript

import i18n from 'i18next';
import Backend from 'i18next-xhr-backend';
const backendI18n = i18n.createInstance();
const API_SERVER_ORIGIN = process.env.REACT_APP_API_SERVER_ORIGIN;
backendI18n
.use(Backend)
// .use(initReactI18next) // passes i18n down to react-i18next
.init({
lng: 'en',
fallbackLng: 'en',
// initImmediate: true,
interpolation: {
escapeValue: false,
},
backend: {
loadPath: `${API_SERVER_ORIGIN}/translations/messages?lang={{lng}}`,
parse: (data: any) => data,
},
react: {
wait: true,
useSuspense: false,
},
});
export default backendI18n;