2025-02-08 18:42:39 -08:00
|
|
|
import i18n from "i18next";
|
|
|
|
|
import { initReactI18next } from "react-i18next";
|
2025-02-07 01:59:54 +03:00
|
|
|
|
2025-05-27 10:01:10 -07:00
|
|
|
const primaryLanguage = "en";
|
2025-02-07 01:59:54 +03:00
|
|
|
|
2025-05-30 15:03:32 -07:00
|
|
|
// Load all translation files eagerly
|
2025-02-08 18:42:39 -08:00
|
|
|
const translations = import.meta.glob("../locales/*.json", { eager: true });
|
2025-02-07 01:59:54 +03:00
|
|
|
|
|
|
|
|
const resources = {};
|
|
|
|
|
Object.keys(translations).forEach((path) => {
|
2025-02-08 18:42:39 -08:00
|
|
|
const langCode = path.match(/\/([^/]+)\.json$/)[1];
|
|
|
|
|
resources[langCode] = {
|
|
|
|
|
translation: translations[path].default || translations[path],
|
|
|
|
|
};
|
2025-02-07 01:59:54 +03:00
|
|
|
});
|
|
|
|
|
|
2025-02-08 18:42:39 -08:00
|
|
|
i18n.use(initReactI18next).init({
|
|
|
|
|
resources,
|
2025-05-30 15:03:32 -07:00
|
|
|
lng: primaryLanguage,
|
2025-02-08 18:42:39 -08:00
|
|
|
fallbackLng: primaryLanguage,
|
|
|
|
|
debug: import.meta.env.MODE === "development",
|
|
|
|
|
ns: ["translation"],
|
|
|
|
|
defaultNS: "translation",
|
|
|
|
|
interpolation: {
|
|
|
|
|
escapeValue: false,
|
|
|
|
|
},
|
|
|
|
|
});
|
2025-02-07 01:59:54 +03:00
|
|
|
|
|
|
|
|
export default i18n;
|