add language detector from i18next

This commit is contained in:
Amruth Pillai
2020-04-11 20:19:16 +05:30
parent ef56d248c9
commit 92b00db932
3 changed files with 31 additions and 7 deletions

View File

@ -1,5 +1,7 @@
import i18n from 'i18next';
import backend from 'i18next-xhr-backend';
import { initReactI18next } from 'react-i18next';
import detector from 'i18next-browser-languagedetector';
import resources from './locales';
@ -46,13 +48,17 @@ const languages = [
},
];
i18n.use(initReactI18next).init({
resources,
lng: 'en',
fallbackLng: 'en',
ns: ['app', 'leftSidebar', 'rightSidebar'],
defaultNS: 'app',
});
i18n
.use(detector)
.use(backend)
.use(initReactI18next)
.init({
resources,
lng: 'en',
fallbackLng: 'en',
ns: ['app', 'leftSidebar', 'rightSidebar'],
defaultNS: 'app',
});
export { languages };