From 262b78744a940dbd1c9f70709d190ec988133279 Mon Sep 17 00:00:00 2001 From: Jessie Keck <jessie.keck@gmail.com> Date: Fri, 1 Feb 2019 16:01:11 -0800 Subject: [PATCH] Install i18next and react-i18next. --- locales/en/translation.json | 3 +++ package.json | 2 ++ src/i18n.js | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 locales/en/translation.json create mode 100644 src/i18n.js diff --git a/locales/en/translation.json b/locales/en/translation.json new file mode 100644 index 000000000..d67e188df --- /dev/null +++ b/locales/en/translation.json @@ -0,0 +1,3 @@ +{ + "translation": {} +} diff --git a/package.json b/package.json index d147f8927..5e0c9cbdd 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "classnames": "^2.2.6", "css-ns": "^1.2.2", "deepmerge": "^3.1.0", + "i18next": "^14.0.1", "intersection-observer": "^0.5.1", "manifesto.js": "^3.0.9", "node-fetch": "^2.3.0", @@ -43,6 +44,7 @@ "react": "^16.7.0", "react-dom": "^16.4.0", "react-fullscreen-crossbrowser": "^1.0.9", + "react-i18next": "^9.0.10", "react-mosaic-component": "^2.0.2", "react-redux": "^6.0.0", "react-virtualized": "^9.21.0", diff --git a/src/i18n.js b/src/i18n.js new file mode 100644 index 000000000..dac6958f0 --- /dev/null +++ b/src/i18n.js @@ -0,0 +1,22 @@ +import i18n from 'i18next'; +import { reactI18nextModule } from 'react-i18next'; +import en from '../locales/en/translation.json'; + +// Load translations for each language +const resources = { + en, +}; + +i18n + .use(reactI18nextModule) + .init({ + resources, + lng: 'en', + fallbackLng: 'en', + + interpolation: { + escapeValue: false, // react is already safe from xss + }, + }); + +export default i18n; -- GitLab