File size: 1,064 Bytes
8a37e0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
import i18n from 'i18next';
import Backend from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';

// TODO: Disabled for IDE performance issues with our translation JSON
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import translationEN from '../public/locales/en.json';

if (import.meta.env.MODE === 'package') {
  i18n.use(initReactI18next).init({
    lng: 'en',
    resources: {
      en: { translation: translationEN },
    },
    debug: false,
    interpolation: {
      escapeValue: false,
    },
    returnNull: false,
  });
} else {
  i18n
    .use(Backend)
    // .use(
    //   new LanguageDetector(null, {
    //     lookupLocalStorage: `${LOCALSTORAGE_PREFIX}lng`,
    //   })
    // )
    .use(initReactI18next)
    .init({
      fallbackLng: 'en',
      debug: false,
      backend: {
        loadPath: `${window.location.href.replace(/\/$/, '')}/locales/{{lng}}.json`,
      },
      interpolation: {
        escapeValue: false,
      },
      returnNull: false,
    });
}

export default i18n;