You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
749 B
28 lines
749 B
import i18n from "i18next"; |
|
import { initReactI18next } from "react-i18next"; |
|
import en from "./en.json"; |
|
import id from "./id.json"; |
|
|
|
const fallbackLng = "en"; |
|
|
|
i18n |
|
.use(initReactI18next) |
|
.init({ |
|
resources: { |
|
en: { translation: en }, |
|
id: { translation: id }, |
|
}, |
|
fallbackLng, |
|
debug: true, |
|
interpolation: { |
|
escapeValue: false, // not needed for react as it escapes by default |
|
}, |
|
lng: localStorage.getItem("language") || fallbackLng, |
|
}); |
|
|
|
// Set up an event listener to update the language in localStorage whenever the language is changed |
|
i18n.on("languageChanged", (lng) => { |
|
localStorage.setItem("language", lng); |
|
}); |
|
|
|
export default i18n;
|
|
|