1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 00:35:00 +00:00
mon-entreprise/source/i18n.js
Maxime Quandalle 139ca46ad1
⚙️ Traduction des unités
Gestion du pluriel (1 jour, 2 jours) et de la traduction (3 days).

Fixes #729
2019-10-13 20:36:22 +02:00

26 lines
652 B
JavaScript

import i18next from 'i18next'
import { initReactI18next } from 'react-i18next'
import enTranslations from './locales/en.yaml'
import unitsTranslations from './locales/units.yaml'
let lang =
new URLSearchParams(document.location.search.substring(1)).get('lang') ||
sessionStorage?.getItem('lang')?.match(/^(fr|en)$/)?.[0] ||
'fr'
sessionStorage?.setItem('lang', lang)
i18next
.use(initReactI18next)
.init({
lng: lang,
resources: {
fr: { units: unitsTranslations.fr },
en: {
translation: enTranslations,
units: unitsTranslations.en
}
}
})
.catch(err => console?.error('Error from i18n load', err))
export default i18next