1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 09:58:13 +09:00

feat: cache locales

This commit is contained in:
2019-08-08 21:34:06 +09:00
parent b27c597cfd
commit 0d4429cb95
3 changed files with 40 additions and 19 deletions

View File

@@ -1,20 +1,19 @@
import i18n from 'i18next'
import Backend from 'i18next-xhr-backend'
import Backend from 'i18next-chained-backend'
import LocalStorageBackend from 'i18next-localstorage-backend'
import XHR from 'i18next-xhr-backend'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'
i18n
// load translation using xhr -> see /public/locales
// learn more: https://github.com/i18next/i18next-xhr-backend
.use(Backend)
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
backend: {
backends: [LocalStorageBackend, XHR],
backendOptions: [],
},
fallbackLng: 'en',
debug: false,
interpolation: {