all repos — caroster @ 5b56ddaba8515a32a5623282ddc378007e8efcb9

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

frontend/lib/i18n.ts (view raw)

 1import i18n from 'i18next';
 2import {initReactI18next} from 'react-i18next';
 3import 'moment/min/locales';
 4import moment from 'moment';
 5import {Enum_Userspermissionsuser_Lang as SupportedLocales} from '../generated/graphql';
 6import translationFr from '../locales/fr.json';
 7import translationEn from '../locales/en.json';
 8import translationNl from '../locales/nl.json';
 9
10const resources = {
11  fr: {
12    translation: translationFr,
13  },
14  en: {
15    translation: translationEn,
16  },
17  nl: {
18    translation: translationNl,
19  },
20};
21
22export const initI18Next = (locale: SupportedLocales) => {
23  i18n
24    .use(initReactI18next) // passes i18n down to react-i18next
25    .init({
26      resources,
27      lng: locale,
28      supportedLngs: ['fr', 'en', 'nl'],
29      fallbackLng: 'en',
30      interpolation: {
31        escapeValue: false, // react already safes from xss
32      },
33    });
34  moment.locale(i18n.language);
35};
36
37export default i18n;