all repos — caroster @ 3c0bbee900166b5b841ef12b7b71dfc5330de1f8

[Octree] Group carpool to your event https://caroster.io

frontend/i18n.ts (view raw)

 1import i18n from 'i18next';
 2import {initReactI18next} from 'react-i18next';
 3import translationFr from './locales/fr.json';
 4import translationEn from './locales/en.json';
 5
 6const resources = {
 7  fr: {
 8    translation: translationFr,
 9  },
10  en: {
11    translation: translationEn,
12  },
13};
14
15const getUserLng = () => typeof window !== 'undefined' && typeof window.navigator !== 'undefined' ? navigator.language : 'en';
16
17i18n
18  .use(initReactI18next) // passes i18n down to react-i18next
19  .init({
20    resources,
21    lng: getUserLng(),
22    supportedLngs: ['fr', 'en'],
23    interpolation: {
24      escapeValue: false, // react already safes from xss
25    },
26  });
27
28export default i18n;