chore: i18n config moved to the app route
This commit is contained in:
16
src/i18n.ts
Normal file
16
src/i18n.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import i18next from 'i18next';
|
||||||
|
import I18NextHttpBackend from 'i18next-http-backend';
|
||||||
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
|
i18next
|
||||||
|
.use(I18NextHttpBackend)
|
||||||
|
.use(initReactI18next)
|
||||||
|
.init({
|
||||||
|
lng: 'en',
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false,
|
||||||
|
},
|
||||||
|
backend: {
|
||||||
|
loadPath: `${window.location.origin}/i18n/{{lng}}.json`,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
import './i18n';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { LanguageProvider } from './providers/LanguageProvider';
|
import { LanguageProvider } from './providers/LanguageProvider';
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,9 @@
|
|||||||
import type { Language } from '@/types/language';
|
import type { Language } from '@/types/language';
|
||||||
import { changeLanguage } from 'i18next';
|
import { changeLanguage } from 'i18next';
|
||||||
import { useLayoutEffect, type JSX, type PropsWithChildren } from 'react';
|
import { useLayoutEffect, type JSX, type PropsWithChildren } from 'react';
|
||||||
import { initReactI18next, useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||||
import { LangaugeContext } from '@/contexts/LangaugeContext';
|
import { LangaugeContext } from '@/contexts/LangaugeContext';
|
||||||
import i18n from 'i18next';
|
|
||||||
import i18nBackend from 'i18next-http-backend';
|
|
||||||
|
|
||||||
i18n
|
|
||||||
.use(i18nBackend)
|
|
||||||
.use(initReactI18next)
|
|
||||||
.init({
|
|
||||||
lng: 'en',
|
|
||||||
interpolation: {
|
|
||||||
escapeValue: false,
|
|
||||||
},
|
|
||||||
backend: {
|
|
||||||
loadPath: `${window.location.origin}/i18n/{{lng}}.json`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const LanguageProvider = (props: PropsWithChildren): JSX.Element => {
|
export const LanguageProvider = (props: PropsWithChildren): JSX.Element => {
|
||||||
const [currentLanguage, setCurrentLangauge] = useLocalStorage<Language>(
|
const [currentLanguage, setCurrentLangauge] = useLocalStorage<Language>(
|
||||||
|
|||||||
Reference in New Issue
Block a user