36 lines
927 B
TypeScript
36 lines
927 B
TypeScript
import i18n from 'i18next';
|
|
import { initReactI18next } from 'react-i18next';
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
|
// Import translation files directly to avoid extra HTTP requests
|
|
// and ensure we don't have issues with Vite's dev server for static assets
|
|
import enTranslation from './locales/en.json';
|
|
import esTranslation from './locales/es.json';
|
|
|
|
const resources = {
|
|
en: {
|
|
translation: enTranslation,
|
|
},
|
|
es: {
|
|
translation: esTranslation,
|
|
},
|
|
};
|
|
|
|
i18n
|
|
.use(LanguageDetector)
|
|
.use(initReactI18next)
|
|
.init({
|
|
resources,
|
|
fallbackLng: 'en',
|
|
showSupportNotice: false,
|
|
interpolation: {
|
|
escapeValue: false, // React already escapes values
|
|
},
|
|
detection: {
|
|
order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag', 'path', 'subdomain'],
|
|
caches: ['localStorage', 'cookie'],
|
|
},
|
|
});
|
|
|
|
export default i18n;
|