2019-04-16 03:06:39 +03:00
|
|
|
import i18next from 'i18next'
|
|
|
|
import XHR from 'i18next-xhr-backend'
|
2019-04-15 19:56:40 +03:00
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector'
|
2019-04-16 03:06:39 +03:00
|
|
|
import { initReactI18next } from 'react-i18next'
|
2018-12-29 08:36:49 +03:00
|
|
|
|
2019-04-16 03:06:39 +03:00
|
|
|
i18next
|
2018-12-29 08:36:49 +03:00
|
|
|
// load translation using xhr -> see /public/locales
|
2019-04-16 03:06:39 +03:00
|
|
|
// https://github.com/i18next/i18next-xhr-backend
|
|
|
|
.use(XHR)
|
2018-12-29 08:36:49 +03:00
|
|
|
// detect user language
|
2019-04-16 03:06:39 +03:00
|
|
|
// https://github.com/i18next/i18next-browser-languageDetector
|
2018-12-29 08:36:49 +03:00
|
|
|
.use(LanguageDetector)
|
2019-04-16 03:06:39 +03:00
|
|
|
.use(initReactI18next)
|
|
|
|
// https://www.i18next.com/overview/configuration-options
|
2018-12-29 08:36:49 +03:00
|
|
|
.init({
|
2019-04-16 03:06:39 +03:00
|
|
|
backend: {
|
|
|
|
loadPath: './locales/{{lng}}.json'
|
|
|
|
},
|
2019-04-15 19:56:40 +03:00
|
|
|
fallbackLng: 'en',
|
2018-12-29 08:36:49 +03:00
|
|
|
keySeparator: false,
|
|
|
|
interpolation: {
|
2019-04-16 03:06:39 +03:00
|
|
|
escapeValue: false // not needed for react as it escapes by default
|
2018-12-29 08:36:49 +03:00
|
|
|
}
|
2019-04-15 19:56:40 +03:00
|
|
|
})
|
2018-12-29 08:36:49 +03:00
|
|
|
|
2019-04-16 03:06:39 +03:00
|
|
|
export default i18next
|