Update: Moved localization to seperate module

This commit is contained in:
Llewellyn D'souza
2022-01-06 10:23:48 +05:30
parent 30668660bb
commit d7c4146228
3 changed files with 27 additions and 22 deletions

View File

@@ -1,27 +1,7 @@
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import Test from './components/Test';
import localizationInit from './config/localization';
i18next
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
supportedLngs: ['en' /*, 'fr'*/],
fallbackLng: 'en',
debug: false,
// Options for language detector
detection: {
order: ['localStorage', 'sessionStorage', 'cookie', 'htmlTag'],
caches: ['localStorage'],
},
// react: { useSuspense: false },
backend: {
loadPath: '/assets/locales/{{lng}}/translation.json',
},
});
localizationInit();
function App() {
return (

View File

@@ -0,0 +1,25 @@
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
export default function localizationInit() {
i18next
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
supportedLngs: ['en' /*, 'fr'*/],
fallbackLng: 'en',
debug: false,
// Options for language detector
detection: {
order: ['localStorage', 'sessionStorage', 'cookie', 'htmlTag'],
caches: ['localStorage'],
},
// react: { useSuspense: false },
backend: {
loadPath: '/assets/locales/{{lng}}/translation.json',
},
});
}

View File