Update: Moved localization to seperate module
This commit is contained in:
24
src/App.js
24
src/App.js
@@ -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 Test from './components/Test';
|
||||||
|
import localizationInit from './config/localization';
|
||||||
|
|
||||||
i18next
|
localizationInit();
|
||||||
.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',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
25
src/config/localization.js
Normal file
25
src/config/localization.js
Normal 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',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user