LibreCharge/frontend/src/lib/i18n.ts

32 lines
818 B
TypeScript

import i18next from 'i18next'
import Backend from 'i18next-chained-backend'
import Fetch from 'i18next-fetch-backend'
import LocalStorageBackend from 'i18next-localstorage-backend'
import I18nextBrowserLanguageDetector from 'i18next-browser-languagedetector'
import { createI18nStore } from './i18n-store'
i18next
.use(Backend)
.use(I18nextBrowserLanguageDetector)
.init({
supportedLngs: ['en', 'de'],
ns: ['common'],
defaultNS: 'common',
backend: {
backends: [LocalStorageBackend, Fetch],
backendOptions: [
{
expirationTime: 24 * 60 * 60 * 1000,
},
{
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
],
},
interpolation: {
escapeValue: false,
},
})
const i18n = createI18nStore(i18next)
export default i18n