import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector"; import "moment/locale/pl" import "moment/locale/en-gb" import moment, { isDuration, isMoment } from "moment"; import { convertToRoman } from "@/utils/numbers"; const resources = { en: { translation: require('../translations/en.yaml'), }, pl: { translation: require('../translations/pl.yaml'), } } i18n .use(I18nextBrowserLanguageDetector) .use(initReactI18next) .init({ resources, fallbackLng: "pl", interpolation: { escapeValue: false, format: (value, format, lng) => { if (typeof value === "number" && format == "roman") { return convertToRoman(value); } if (isMoment(value)) { return value.locale(lng || "pl").format(format || "DD MMM YYYY"); } if (isDuration(value)) { return value.locale(lng || "pl").humanize(); } return value; } } }) document.documentElement.lang = i18n.language; moment.locale(i18n.language) export default i18n;