feat: first shoot on translation
This commit is contained in:
42
src/i18n/i18n.ts
Normal file
42
src/i18n/i18n.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
|
||||
// Importation des traductions
|
||||
import frCommon from "./messages/fr/common.json";
|
||||
import enCommon from "./messages/en/common.json";
|
||||
|
||||
// Ne pas initialiser i18next plus d'une fois
|
||||
if (!i18n.isInitialized) {
|
||||
i18n
|
||||
.use(LanguageDetector) // Détecte la langue du navigateur
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources: {
|
||||
fr: {
|
||||
common: frCommon,
|
||||
},
|
||||
en: {
|
||||
common: enCommon,
|
||||
},
|
||||
},
|
||||
defaultNS: "common",
|
||||
fallbackLng: "fr",
|
||||
interpolation: {
|
||||
escapeValue: false, // React gère déjà l'échappement
|
||||
},
|
||||
detection: {
|
||||
order: ["cookie", "localStorage", "navigator"],
|
||||
lookupCookie: "NEXT_LOCALE",
|
||||
caches: ["cookie"],
|
||||
cookieOptions: {
|
||||
path: "/",
|
||||
maxAge: 365 * 24 * 60 * 60, // 1 an
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default i18n;
|
||||
Reference in New Issue
Block a user