// utils-lib.js lives outside of the front-end/app project import { initReactI18next } from "react-i18next"; export const i18nInstance = i18n .use(otherThings) .use(initReactI18next); // App.tsx or App root import { i18nInstance } from 'utils-lib'; const App = () => <I18nextProvider i18n={i18nInstance}> <MyComp /> </I18nextProvider> import { useTranslation } from 'react-i18next'; const MyComp = () => { const { t, i18n } = useTranslation(); return <div>{t('tag')}</div> } i18nInstance.init(generateI18nInitOptions(), error => { // handle your errors });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter