Files
package-browser/src/i18n.tsx
2025-01-12 17:12:43 +02:00

47 lines
823 B
TypeScript

import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import {
initReactI18next
} from "react-i18next";
import {
ENGLISH
} from './locales/en';
import {
UKRAINIAN
} from './locales/uk';
const resources = {
en: {
translation: ENGLISH
},
uk: {
translation: UKRAINIAN
}
};
i18n.use(initReactI18next).use(LanguageDetector).init({
resources,
fallbackLng: (localStorage.getItem('selectedLanguage') || "en"),
interpolation: {
escapeValue: false
},
detection: {
order: ['localStorage', 'navigator'],
caches: ['localStorage']
}
});
export const translate = (key: string, options?: {
[key: string]: any
}): string => {
return i18n.t(key, options);
};
export default i18n;