veza/apps/web/src/lib/i18n.ts
senke 24579b87c3 feat(v0.12.7): internationalisation i18n — FR/EN/ES avec formatage locale
- Ajout traductions espagnol (es.json, 532 clés)
- Extension type Language à 'en' | 'fr' | 'es' dans tous les stores/hooks/types
- Formatage dates/nombres/monnaies selon la locale courante (Intl API)
- Utilitaires formatNumber() et formatCurrency() ajoutés
- Temps relatifs localisés (en/fr/es) dans date.ts
- PreferenceSettings utilise i18n pour les labels (plus de hardcoded French)
- Synchronisation i18n immédiate au changement de langue (sans rechargement)
- Tests: 50 tests passent (useTranslation + date utilities, 3 locales)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 14:29:22 +01:00

45 lines
913 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';
import es from '@/locales/es.json';
const resources = {
fr: {
translation: fr,
},
en: {
translation: en,
},
es: {
translation: es,
},
};
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;