i18n.ts
1 import i18n from "i18next"; 2 import Backend from "i18next-http-backend"; 3 import { initReactI18next } from "react-i18next"; 4 import LanguageDetector from "i18next-browser-languagedetector"; 5 6 i18n 7 .use(Backend) 8 .use(LanguageDetector) 9 .use(initReactI18next) 10 .init({ 11 lng: "es", 12 backend: { 13 /* translation file path */ 14 loadPath: "/assets/i18n/{{ns}}/{{lng}}.json", 15 }, 16 fallbackLng: "es", 17 debug: true, 18 /* can have multiple namespace, in case you want to divide a huge translation into smaller pieces and load them on demand */ 19 ns: ["translations"], 20 defaultNS: "translations", 21 keySeparator: false, 22 interpolation: { 23 escapeValue: false, 24 formatSeparator: ",", 25 }, 26 react: { 27 useSuspense: true, 28 }, 29 }); 30 31 export default i18n;