Files
Checkmate/client/src/Utils/i18n.js
T

29 lines
713 B
JavaScript
Raw Normal View History

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
2025-02-07 01:59:54 +03: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
const translations = import.meta.glob("../locales/*.json", { eager: true });
2025-02-07 01:59:54 +03:00
const resources = {};
Object.keys(translations).forEach((path) => {
const langCode = path.match(/\/([^/]+)\.json$/)[1];
resources[langCode] = {
translation: translations[path].default || translations[path],
};
2025-02-07 01:59:54 +03:00
});
i18n.use(initReactI18next).init({
resources,
2025-05-30 15:03:32 -07:00
lng: primaryLanguage,
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;