All files / src i18n.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                    8x                                         8x 4x        
import dayjs from 'dayjs';
import 'dayjs/locale/fr';
import 'dayjs/locale/de';
import 'dayjs/locale/en';
 
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend'
 
i18n
  .use(Backend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    backend: {
      loadPath: '/locales/{{lng}}/{{ns}}.json',
    },
    fallbackLng: 'en',
    supportedLngs: ['fr','en','de'],
    detection: {
      order: ['querystring', 'cookie', 'navigator'],
      caches: ['cookie'],
    },
    ns: ['common', 'legal', 'privacy', 'terms', 'contact', 'home', 'ticket', 'cart', 'login', 'errors', 'signup', 'verification', 'passwordReset', 'forgotPassword', 'userDashboard', 'tickets', 'invoices', 'checkout', 'unauthorized'],
    defaultNS: 'common',
    fallbackNS: 'errors',
    interpolation: { escapeValue: false },
    react: { useSuspense: false },
  });
 
  i18n.on('languageChanged', (lng) => {
    dayjs.locale(['fr','de','en'].includes(lng) ? lng : 'en');
  });
 
export default i18n;