diff --git a/web/src/App/Sidebar.jsx b/web/src/App/Sidebar.jsx index 26fec55..a999a84 100644 --- a/web/src/App/Sidebar.jsx +++ b/web/src/App/Sidebar.jsx @@ -18,7 +18,6 @@ import { AppSidebarStyle } from './style' export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) { const [currentLang, changeLang] = useChangeLanguage() - const { t } = useTranslation() return ( diff --git a/web/src/i18n.js b/web/src/i18n.js new file mode 100644 index 0000000..02e6349 --- /dev/null +++ b/web/src/i18n.js @@ -0,0 +1,16 @@ +import i18n from 'i18next' +import { initReactI18next } from 'react-i18next' +import LanguageDetector from 'i18next-browser-languagedetector' +import translationEN from 'locales/en/translation.json' +import translationRU from 'locales/ru/translation.json' + +i18n + .use(LanguageDetector) + .use(initReactI18next) + .init({ + fallbackLng: 'en', // default + interpolation: { escapeValue: false }, // react already safes from xss + resources: { en: { translation: translationEN }, ru: { translation: translationRU } }, + }) + +export default i18n diff --git a/web/src/index.jsx b/web/src/index.jsx index 898f403..02a1c7f 100644 --- a/web/src/index.jsx +++ b/web/src/index.jsx @@ -1,40 +1,13 @@ import { StrictMode } from 'react' import ReactDOM from 'react-dom' -import { I18nextProvider } from 'react-i18next' -import i18n from 'i18next' -import LanguageDetector from 'i18next-browser-languagedetector' +import 'i18n' import './index.css' import App from './App' -i18n.use(LanguageDetector).init({ - lng: 'en', // default - fallbackLng: 'en', // use en if detected lng is not available - keySeparator: false, // we do not use keys in form messages.welcome - interpolation: { - escapeValue: false, // react already safes from xss - }, - resources: { - en: { - // eslint-disable-next-line global-require - translations: require('./locales/en/translation.json'), - }, - ru: { - // eslint-disable-next-line global-require - translations: require('./locales/ru/translation.json'), - }, - }, - ns: ['translations'], - defaultNS: 'translations', -}) - -i18n.languages = ['en', 'ru'] - ReactDOM.render( - - - + , document.getElementById('root'), )