aboutsummaryrefslogtreecommitdiffstats
path: root/src/i18n.js
blob: dbbb4d9ea26e290c2f1fdd8bdc6eb4d5f78296ee (plain)
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
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
import { Translations } from './translations';

// i18n wants a single object in the following format:
// {
//   'en-US': {
//     translation: {
//       title: 'WiFi Card',,
//       ...
//     }
//   },
// }
const resources = Translations.reduce((obj, curr) => {
  obj[curr.id] = curr;
  return obj;
}, {});

i18n
  .use(initReactI18next)
  .use(LanguageDetector)
  .init({
    fallbackLng: 'en-US',
    resources,
    interpolation: {
      escapeValue: false,
    },
  });

export default i18n;