41 lines
843 B
TypeScript
41 lines
843 B
TypeScript
import i18n from 'i18next';
|
|
import { initReactI18next } from 'react-i18next';
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
|
// Import des traductions
|
|
import fr from '@/locales/fr.json';
|
|
import en from '@/locales/en.json';
|
|
|
|
const resources = {
|
|
fr: {
|
|
translation: fr,
|
|
},
|
|
en: {
|
|
translation: en,
|
|
},
|
|
};
|
|
|
|
i18n
|
|
.use(LanguageDetector)
|
|
.use(initReactI18next)
|
|
.init({
|
|
resources,
|
|
fallbackLng: 'en',
|
|
debug: import.meta.env.VITE_DEBUG === 'true',
|
|
|
|
interpolation: {
|
|
escapeValue: false, // React échappe déjà les valeurs
|
|
},
|
|
|
|
detection: {
|
|
order: ['localStorage', 'navigator', 'htmlTag'],
|
|
caches: ['localStorage'],
|
|
},
|
|
});
|
|
|
|
// Exposer i18n sur window pour synchronisation avec Zustand
|
|
if (typeof window !== 'undefined') {
|
|
window.i18n = i18n;
|
|
}
|
|
|
|
export default i18n;
|