i18n.ts (1215B)
1 import i18n from 'i18next'; 2 import { initReactI18next } from 'react-i18next'; 3 4 import Backend from 'i18next-http-backend'; 5 import LanguageDetector from 'i18next-browser-languagedetector'; 6 7 // don't want to use this? 8 // have a look at the Quick start guide 9 // for passing in lng and translations on init 10 11 i18n 12 // load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales) 13 // learn more: https://github.com/i18next/i18next-http-backend 14 // want your translations to be loaded from a professional CDN? => https://github.com/locize/react-tutorial#step-2---use-the-locize-cdn 15 .use(Backend) 16 // detect user language 17 // learn more: https://github.com/i18next/i18next-browser-languageDetector 18 .use(LanguageDetector) 19 // pass the i18n instance to react-i18next. 20 .use(initReactI18next) 21 // init i18next 22 // for all options read: https://www.i18next.com/overview/configuration-options 23 .init({ 24 fallbackLng: 'en', 25 debug: true, 26 27 interpolation: { 28 escapeValue: false, // not needed for react as it escapes by default 29 } 30 }); 31 32 export { default } from 'i18next';