feat: add i18next (#11)

This commit is contained in:
2024-11-03 12:52:50 +03:00
parent 7ff8a99505
commit 9a490bd993
6 changed files with 50 additions and 14 deletions

View File

@@ -1,19 +1,26 @@
/* eslint-disable react/display-name */
import React from 'react';
import ReactDOM from 'react-dom/client';
import { i18nextReactInitConfig } from '@brojs/i18nextreactconfig';
import App from './app';
import i18next from 'i18next';
i18next.t = i18next.t.bind(i18next);
const i18nextPromise = i18nextReactInitConfig(i18next);
export default () => <App />;
let rootElement: ReactDOM.Root;
export const mount = (Component, element = document.getElementById('app')) => {
export const mount = async (
Component,
element = document.getElementById('app'),
) => {
const rootElement = ReactDOM.createRoot(element);
await i18nextPromise;
rootElement.render(<Component />);
if (module.hot) {
module.hot.accept('./app', () => {
module.hot.accept('./app', async () => {
await i18next.reloadResources();
rootElement.render(<Component />);
});
}