github.com/lauslim12/expert-systems@v0.0.0-20221115131159-018513aad29c/web/src/utils/i18n.ts (about) 1 import i18n from 'i18next'; 2 import LanguageDetector from 'i18next-browser-languagedetector'; 3 import Backend from 'i18next-http-backend'; 4 import { initReactI18next } from 'react-i18next'; 5 6 // Settings from: https://react.i18next.com/latest/using-with-hooks. 7 i18n 8 // Load translations with HTTP. 9 .use(Backend) 10 11 // Checks the language which the user prefers. 12 .use(LanguageDetector) 13 14 // Pass i18n instance. 15 .use(initReactI18next) 16 17 // Initialize all. Translations are fetched automatically from 'public/locales/<lang_code>/translation.json'. 18 .init({ 19 fallbackLng: 'en', 20 debug: process.env.NODE_ENV === 'development', 21 interpolation: { 22 escapeValue: false, 23 }, 24 }); 25 26 export default i18n;