mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-03 22:25:27 +00:00
a20a0a6b38
Add Spanish to the language selection system on both trees, with 872 frontend phrases and 145 backend ones translated from the French source. The frontend to backend language map gains it too, so a Spanish browser does not write an empty language to the account on every load.
35 lines
950 B
TypeScript
35 lines
950 B
TypeScript
import i18n from 'i18next'
|
|
import resourcesToBackend from 'i18next-resources-to-backend'
|
|
import { initReactI18next } from 'react-i18next'
|
|
import LanguageDetector from 'i18next-browser-languagedetector'
|
|
const i18nDefaultNamespace = 'global'
|
|
const fallbackLng = 'fr'
|
|
|
|
i18n.setDefaultNamespace(i18nDefaultNamespace)
|
|
i18n
|
|
.use(
|
|
resourcesToBackend((language: string, namespace: string) => {
|
|
return import(`../locales/${language}/${namespace}.json`)
|
|
})
|
|
)
|
|
.use(initReactI18next)
|
|
.use(LanguageDetector)
|
|
.init({
|
|
supportedLngs: ['en', 'fr', 'nl', 'de', 'es'],
|
|
fallbackLng,
|
|
ns: i18nDefaultNamespace,
|
|
detection: {
|
|
order: ['localStorage', 'navigator'],
|
|
},
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
})
|
|
.then(() => {
|
|
document.documentElement.setAttribute('lang', i18n.language || fallbackLng)
|
|
})
|
|
|
|
i18n.on('languageChanged', (lang) => {
|
|
document.documentElement.setAttribute('lang', lang)
|
|
})
|